I am running Python 2.5.4 compiled with gcc (Gentoo 4.3.2-r2 p1.5, pie-10.1.5) 4.3.2 My program uses python interface to two C modules namely libnids (pynids) and adns (adns-python). My program is written all in python. When I run my program it aborts. Here is the stack when that happens: #0 0x00007f6cfdb79205 in raise () from /lib64/libc.so.6 #1 0x00007f6cfdb7a723 in abort () from /lib64/libc.so.6 #2 0x00007f6cfdbb4cf8 in ?? () from /lib64/libc.so.6 #3 0x00007f6cfdbba468 in ?? () from /lib64/libc.so.6 #4 0x00007f6cfdbbbfa6 in free () from /lib64/libc.so.6 #5 0x00007f6cfe79dff2 in ?? () from /usr/lib/libpython2.5.so.1.0 #6 0x00007f6cfe7fd736 in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0 #7 0x00007f6cfe7fde7d in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0 #8 0x00007f6cfe79f5ce in ?? () from /usr/lib/libpython2.5.so.1.0 #9 0x00007f6cfe781e27 in PyObject_Call () from /usr/lib/libpython2.5.so.1.0 #10 0x00007f6cfe782187 in ?? () from /usr/lib/libpython2.5.so.1.0 #11 0x00007f6cfe7826c8 in PyObject_CallFunction () from /usr/lib/libpython2.5.so.1.0 #12 0x00007f6cfd939b41 in callTcpFunc () from /usr/lib64/python2.5/site-packages/nidsmodule.so #13 0x00007f6cfd93ebae in process_tcp (data=0x1a2f930 "E", skblen=248) at tcp.c:805 #14 0x00007f6cfd93bd7a in gen_ip_proc (data=0x1a2f930 "E", skblen=248) at libnids.c:436 #15 0x00007f6cfd93bbd8 in gen_ip_frag_proc (data=0x1a2f930 "E", len=46) at libnids.c:388 #16 0x00007f6cfd93b6a3 in call_ip_frag_procs (data=0x1a2f930, caplen=46) at libnids.c:198 #17 0x00007f6cfd93ba05 in nids_pcap_handler (par=0x0, hdr=0x7fff06cc3500, data=0x1a2f922 "") at libnids.c:340 #18 0x00007f6cfd7195d9 in pcap_offline_read () from /usr/lib/libpcap.so.1 #19 0x00007f6cfd93c809 in nids_dispatch (cnt=1) at libnids.c:743 #20 0x00007f6cfd939345 in nids_dispatch_exc () from /usr/lib64/python2.5/site-packages/nidsmodule.so #21 0x00007f6cfd93a980 in pynids_run () from /usr/lib64/python2.5/site-packages/nidsmodule.so #22 0x00007f6cfe7fcacd in PyEval_EvalFrameEx () from /usr/lib/libpython2.5.so.1.0 #23 0x00007f6cfe7fde7d in PyEval_EvalCodeEx () from /usr/lib/libpython2.5.so.1.0 #24 0x00007f6cfe7fe062 in PyEval_EvalCode () from /usr/lib/libpython2.5.so.1.0 #25 0x00007f6cfe818601 in ?? () from /usr/lib/libpython2.5.so.1.0 #26 0x00007f6cfe8186d6 in PyRun_FileExFlags () from /usr/lib/libpython2.5.so.1.0 #27 0x00007f6cfe819c6d in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.5.so.1.0 #28 0x00007f6cfe82337a in Py_Main () from /usr/lib/libpython2.5.so.1.0 #29 0x00007f6cfdb655c6 in __libc_start_main () from /lib64/libc.so.6 #30 0x0000000000400789 in _start () When I run under valgrind I see a whole bunch of memory errors. Two of them are show below. ==26882== Thread 1: ==26882== Invalid free() / delete / delete[] ==26882== at 0x4C239FF: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==26882== by 0x4E84FF1: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4735: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4E7C: PyEval_EvalCodeEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E865CD: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E68E26: PyObject_Call (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E69186: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E696C7: PyObject_CallFunction (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x618FB40: callTcpFunc (in /usr/lib64/python2.5/site-packages/nidsmodule.so) ==26882== by 0x6194BAD: process_tcp (tcp.c:805) ==26882== by 0x6191D79: gen_ip_proc (libnids.c:436) ==26882== by 0x6191BD7: gen_ip_frag_proc (libnids.c:388) ==26882== Address 0x9195230 is 168,568 bytes inside a block of size 262,144 alloc'd ==26882== at 0x4C24CFE: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==26882== by 0x4E9BEE8: PyObject_Malloc (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4F0B468: _PyObject_GC_Malloc (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4F0B55D: _PyObject_GC_NewVar (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EAB313: PyTuple_New (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EF9B28: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EFA0A0: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EF9B75: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EFA08A: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EFA755: PyMarshal_ReadObjectFromString (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EFC272: PyMarshal_ReadLastObjectFromFile (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EF453D: (within /usr/lib64/libpython2.5.so.1.0) ==26882== Invalid read of size 4 ==26882== at 0x4E9C20B: PyObject_Realloc (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EA622E: _PyString_Resize (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EDE458: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE3128: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4715: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4715: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4715: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4E7C: PyEval_EvalCodeEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E865CD: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E68E26: PyObject_Call (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E69186: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E696C7: PyObject_CallFunction (in /usr/lib64/libpython2.5.so.1.0) ==26882== Address 0xb380020 is 280 bytes inside a block of size 1,104 free'd ==26882== at 0x4C239FF: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==26882== by 0x4F14E2B: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4F1A09A: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE3ACC: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4715: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4715: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4715: PyEval_EvalFrameEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4EE4E7C: PyEval_EvalCodeEx (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E865CD: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E68E26: PyObject_Call (in /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E69186: (within /usr/lib64/libpython2.5.so.1.0) ==26882== by 0x4E696C7: PyObject_CallFunction (in /usr/lib64/libpython2.5.so.1.0) So I am not sure where the error is. Any clue on where the bug possibly may be: adns-python, pynids or python? Or how I should I go about debugging this? -Sushant.
So I am not sure where the error is. Any clue on where the bug possibly may be: adns-python, pynids or python? Or how I should I go about debugging this?
This is out of scope for python-dev, but I give some clues anyway: - try finding out what kind of object is being released. Is it a good PyObject*? If so, what is its type? - try running Python in debug mode; this will add additional checks on memory sanity. HTH, Martin
Sushant Sinha wrote:
I am running Python 2.5.4 compiled with gcc (Gentoo 4.3.2-r2 p1.5, pie-10.1.5) 4.3.2
My program uses python interface to two C modules namely libnids (pynids) and adns (adns-python). My program is written all in python. When I run my program it aborts.
As Martin said, this is off-topic for python-dev until the problem has been demonstrated to be in the interpreter itself rather than in the extension modules (mis)use of the interpreter's C API. Until then, comp.lang.python or the user lists for those two C extension modules would be a more appropriate place to ask the question. Cheers, Nick. P.S. (From a quick glance at the stack trace, my initial bet would be on python-nids PCAP handling calling back in to the C API without reacquiring the GIL first) -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------
One more thing: There's a mailing list specifically for help with C extensions, capi@python.org -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ Weinberg's Second Law: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.
participants (4)
-
"Martin v. Löwis"
-
Aahz
-
Nick Coghlan
-
Sushant Sinha