You are not logged in.

#1 2006-01-29 12:05:56

LuNaTiC
Member
Registered: 2006-01-29
Posts: 13

[BUG?] Python, Swig and PyGame

I think I've found a bug related to Python and glibc.
I have recompiled on Arch Linux a neural network library written in C and a "neural pong" game written in Python and PyGame which uses the C library through Swig (Python, PyGame and Swig where installed through pacman).
Here's the package:
http://alessandropresta.altervista.org/ … bug.tar.gz (right click, save link as...)
It compiles fine and -Wall returns no warnings, but when I execute ./neuralpong.py and then close it I get this error message:

*** glibc detected *** python: corrupted double-linked list: 0xb7cb98b8 ***
======= Backtrace: =========
/lib/tls/libc.so.6[0xb7c01233]
/lib/tls/libc.so.6[0xb7c0137f]
/lib/tls/libc.so.6[0xb7c01965]
/lib/tls/libc.so.6(__libc_free+0x84)[0xb7c01c94]
/usr/lib/libpython2.4.so.1.0(PyObject_Free+0x51)[0xb7e3ad31]
/usr/lib/libpython2.4.so.1.0(PyGrammar_RemoveAccelerators+0x6f)[0xb7e0083f]
/usr/lib/libpython2.4.so.1.0(Py_Finalize+0x12d)[0xb7e9a4dd]
/usr/lib/libpython2.4.so.1.0(Py_Main+0x6f3)[0xb7ea12b3]
python(main+0x2a)[0x80485ca]
/lib/tls/libc.so.6(__libc_start_main+0xdb)[0xb7bb1d6b]
python[0x8048511]
======= Memory map: ========
08048000-08049000 r-xp 00000000 03:03 3841282    /usr/bin/python
08049000-0804a000 rw-p 00000000 03:03 3841282    /usr/bin/python
0804a000-08166000 rw-p 0804a000 00:00 0          [heap]
b6335000-b6336000 rw-p b6335000 00:00 0
b64c0000-b64c1000 ---p b64c0000 00:00 0
b64c1000-b6cc1000 rwxp b64c1000 00:00 0
b6cc1000-b6cc8000 r-xp 00000000 03:03 3952350    /usr/X11R6/lib/libXrender.so.1.2.2
b6cc8000-b6cc9000 rw-p 00006000 03:03 3952350    /usr/X11R6/lib/libXrender.so.1.2.2
b6cc9000-b6cd1000 r-xp 00000000 03:03 3952197    /usr/X11R6/lib/libXcursor.so.1.0.2
b6cd1000-b6cd2000 rw-p 00007000 03:03 3952197    /usr/X11R6/lib/libXcursor.so.1.0.2
b6cd2000-b6cd3000 ---p b6cd2000 00:00 0
b6cd3000-b74d3000 rwxp b6cd3000 00:00 0
b74d3000-b75cf000 r-xp 00000000 03:03 3804183    /usr/lib/libcrypto.so.0.9.7
b75cf000-b75e2000 rw-p 000fb000 03:03 3804183    /usr/lib/libcrypto.so.0.9.7
b75e2000-b75e5000 rw-p b75e2000 00:00 0
b75e5000-b7614000 r-xp 00000000 03:03 3804179    /usr/lib/libssl.so.0.9.7
b7614000-b7617000 rw-p 0002f000 03:03 3804179    /usr/lib/libssl.so.0.9.7
b7624000-b7626000 r-xp 00000000 03:03 3964995    /usr/X11R6/lib/X11/locale/lib/common/xlcDef.so.2
b7626000-b7627000 rw-p 00001000 03:03 3964995    /usr/X11R6/lib/X11/locale/lib/common/xlcDef.so.2
b7627000-b762a000 r-xp 00000000 03:03 4000423    /usr/lib/python2.4/lib-dynload/_ssl.so
b762a000-b762b000 rw-p 00003000 03:03 4000423    /usr/lib/python2.4/lib-dynload/_ssl.so
b762b000-b7634000 r-xp 00000000 03:03 4000443    /usr/lib/python2.4/lib-dynload/_socket.so
b7634000-b7637000 rw-p 00009000 03:03 4000443    /usr/lib/python2.4/lib-dynload/_socket.so
b7637000-b7639000 r-xp 00000000 03:03 4097459    /usr/lib/python2.4/site-packages/pygame/fastevent.so
b7639000-b763a000 rw-p 00002000 03:03 4097459    /usr/lib/python2.4/site-packages/pygame/fastevent.so
b763a000-b763c000 r-xp 00000000 03:03 4097452    /usr/lib/python2.4/site-packages/pygame/sndarray.so
b763c000-b763d000 rw-p 00001000 03:03 4097452    /usr/lib/python2.4/site-packages/pygame/sndarray.so
b763d000-b7640000 r-xp 00000000 03:03 4000390    /usr/lib/python2.4/lib-dynload/cStringIO.so
b7640000-b7641000 rw-p 00003000 03:03 4000390    /usr/lib/python2.4/lib-dynload/cStringIO.so
b7641000-b7645000 r-xp 00000000 03:03 4000404    /usr/lib/python2.4/lib-dynload/struct.so
b7645000-b7646000 rw-p 00004000 03:03 4000404    /usr/lib/python2.4/lib-dynload/struct.so
b7646000-b7654000 r-xp 00000000 03:03 4097414    /usr/lib/python2.4/site-packages/Numeric/umath.so
b7654000-b7656000 rw-p 0000d000 03:03 4097414    /usr/lib/python2.4/site-packages/Numeric/umath.so
b7656000-b765c000 r-xp 00000000 03:03 4097395    /usr/lib/python2.4/site-packages/Numeric/multiarray.so
b765c000-b765d000 rw-p 00006000 03:03 4097395    /usr/lib/python2.4/site-packages/Numeric/multiarray.so
b765d000-b766f000 r-xp 00000000 03:03 4097402    /usr/lib/python2.4/site-packages/Numeric/_numpy.so
b766f000-b7671000 rw-p 00011000 03:03 4097402    /usr/lib/python2.4/site-packages/Numeric/_numpy.so
b7671000-b7675000 r-xp 00000000 03:03 4097451    /usr/lib/python2.4/site-packages/pygame/surfarray.so
b7675000-b7677000 rw-p 00004000 03:03 4097451    /usr/lib/python2.4/site-packages/pygame/surfarray.so
b7677000-b76b3000 r-xp 00000000 03:03 3805836    /usr/lib/libsmpeg-0.4.so.0.1.3
b76b3000-b76b5000 rw-p 0003b000 03:03 3805836    /usr/lib/libsmpeg-0.4.so.0.1.3
b76b5000-b76d1000 rw-p b76b5000 00:00 0
b76d1000-b76d4000 r-xp 00000000 03:03 4097453    /usr/lib/python2.4/site-packaAborted

This ONLY happens when I close the app after having started playing, so it could be connected not to PyGame and SDL but to Swig: when the game starts, the neural computation also starts and this is managed by a Swig-compiled module.
I only get this error on Arch; the same sources compiled on Vector Linux (where I used Python 2.3 instead of 2.4) run fine also on Arch.
I hope this issue will be solved.
Ask me for more clarifications.
Thanks in advance smile (and forgive my poor English)

Offline

#2 2006-01-31 23:17:25

JGC
Developer
Registered: 2003-12-03
Posts: 1,664

Re: [BUG?] Python, Swig and PyGame

Try running it in valgrind, it should give you quite some error output I guess.

Offline

#3 2006-02-02 18:16:26

LuNaTiC
Member
Registered: 2006-01-29
Posts: 13

Re: [BUG?] Python, Swig and PyGame

I'm not very good at debugging, but "valgrind neuralpong.py" didn't give me any messages other than the ones listed in my first post.

Offline

#4 2006-02-03 00:32:48

JGC
Developer
Registered: 2003-12-03
Posts: 1,664

Re: [BUG?] Python, Swig and PyGame

Somehow python does bad things. Try valgrind python and see what happens wink

Edit: seems that is normal, because python has its own malloc manager...

Offline

#5 2006-02-03 13:43:10

LuNaTiC
Member
Registered: 2006-01-29
Posts: 13

Re: [BUG?] Python, Swig and PyGame

So the issue is in the conversion of the malloc() calls contained in my library.
I think this only happens with gcc4.
Anyway, is there a way to hide that annoying messages? I've tried to redirect the output of "./neuralpong.py" to /dev/null but it doesn't work.
Thanks

Offline

#6 2006-02-03 15:21:57

JGC
Developer
Registered: 2003-12-03
Posts: 1,664

Re: [BUG?] Python, Swig and PyGame

There are two ways to hide the annoying message:
- fix the bug
- turn off the malloc debugger

glibc, starting from 2.3.4 and up, dump a complete backtrace to your terminal whenever an invalid free or something with corrupt pointers occurs.

Offline

#7 2006-02-03 18:04:13

LuNaTiC
Member
Registered: 2006-01-29
Posts: 13

Re: [BUG?] Python, Swig and PyGame

Since (as I think) the bug is related to Python and Gcc4 and not to my module, I'm not able to fix it.
Anyway, how can I turn the malloc debugger off?

Offline

Board footer

Powered by FluxBB