Recently i have been working on programming python module with C extension. ( python2.7, gcc 4.1.2) Once done and testing. i found following bus error.
does anybody know why?
p.s before i got this error. i fixed 'return Py_False related error' described in
Application gives segmentation fault randomly in python extension functions in c++
Core was generated by python2.7 app.py --debug=False --multi_slaves=True
Program terminated with signal 7, Bus error.
#0 0x0000003d22272cf1 in _int_malloc () from /lib64/libc.so.6
(gdb) where
#0 0x0000003d22272cf1 in _int_malloc () from /lib64/libc.so.6
#1 0x0000003d22274e4e in malloc () from /lib64/libc.so.6
#2 0x00000000004d3069 in _PyObject_GC_Malloc (basicsize=<value optimized out>) at Modules/gcmodule.c:1445
#3 0x000000000046408c in PyType_GenericAlloc (type=0x768360, nitems=0) at Objects/typeobject.c:753
#4 0x00000000004477ec in dict_new (type=0x3d225539e0, args=, kwds=0x7fff8dcb4eb0) at Objects/dictobject.c:2301
#5 0x00000000004661c3 in type_call (type=0x3d225539e0, args=0x2b3e5a521050, kwds=0x2239bca0) at Objects/typeobject.c:721
#6 0x00000000004189cd in PyObject_Call (func=0x768360, arg=0x2b3e5a521050, kw=0x2239bca0) at Objects/abstract.c:2529
c extension code looks like this
static PyObject* analyze( PyObject *self, PyObject *args )
{
int ret;
char* in;
// global variables : void* obj, char* outbuf, int outbuf_size;
if (PyArg_ParseTuple(args, "s", &in)){
ret = process(obj, in, outbuf, outbuf_size);
if ( ret == SUCCESS ) {
PyObject* py_out = PyString_FromString(outbuf);
return py_out;
} else {
Py_INCREF(Py_False);
return Py_False;
}
} else {
Py_INCREF(Py_False);
return Py_False;
}
}
~
analyze, the actual error is most likely somewhere completely different (say, a doublefree). Can you post complete code that still exhibits the problem? Also, the example code is obviously invalid -outbufis never declared.--debug=Trueand run your code through a debugger; that should at least give you the exact point where things crash.