[Python-Dev] python seg faults

Sushant Sinha sushant354 at gmail.com
Wed Feb 11 19:57:46 CET 2009


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090211/0a381db7/attachment-0001.htm>


More information about the Python-Dev mailing list