Closed GoogleCodeExporter closed 8 years ago
Chipmunk doesn't use any glibc directly. I'm guessing that is an error coming
out of GLUT possibly or a memory corruption problem from Chipmunk? Can you
provide any more details of what causes the problem or a stack trace?
Original comment by slemb...@gmail.com
on 15 Aug 2010 at 4:22
[deleted comment]
Here's the backtrace from gdb after a Debug build: it always occurs when the
shape hits the sensor:
(gdb) bt
#0 0x00007ffff685d4b5 in raise () from /lib/libc.so.6
#1 0x00007ffff6860f50 in abort () from /lib/libc.so.6
#2 0x00007ffff68961b7 in ?? () from /lib/libc.so.6
#3 0x00007ffff68a02f6 in ?? () from /lib/libc.so.6
#4 0x00007ffff68a1c19 in ?? () from /lib/libc.so.6
#5 0x00007ffff68a4c6c in free () from /lib/libc.so.6
#6 0x00007ffff49efa3b in ?? () from /usr/lib/tls/libnvidia-tls.so.1
#7 0x000000000041c3e5 in cpShapeFree (shape=0x6de8f0) at
/home/alashtar/projects/chipmunks/src/cpShape.c:81
#8 0x000000000040e39a in postStepRemove (space=0x8f2c60, shape=0x6de8f0,
unused=0x0) at /home/alashtar/projects/chipmunks/Demo/Sensors.c:73
#9 0x000000000042a2d3 in postStepCallbackSetIter (callback=0x6ded70,
space=0x8f2c60) at /home/alashtar/projects/chipmunks/src/cpSpace.c:893
#10 0x0000000000427cd3 in cpHashSetEach (set=0x6df130, func=0x42a29f
<postStepCallbackSetIter>, data=0x8f2c60) at
/home/alashtar/projects/chipmunks/src/cpHashSet.c:224
#11 0x000000000042b213 in cpSpaceStep (space=0x8f2c60, dt=0.01666666753590107)
at /home/alashtar/projects/chipmunks/src/cpSpace.c:1197
#12 0x000000000040e5d3 in update (ticks=143) at
/home/alashtar/projects/chipmunks/Demo/Sensors.c:108
#13 0x000000000040c9a7 in display () at
/home/alashtar/projects/chipmunks/Demo/ChipmunkDemo.c:232
#14 0x00007ffff7bb9d7b in ?? () from /usr/lib/libglut.so.3
#15 0x00007ffff7bbd39b in fgEnumWindows () from /usr/lib/libglut.so.3
#16 0x00007ffff7bba284 in glutMainLoopEvent () from /usr/lib/libglut.so.3
#17 0x00007ffff7bbac97 in glutMainLoop () from /usr/lib/libglut.so.3
#18 0x000000000040d17a in main (argc=1, argv=0x7fffffffe328) at
/home/alashtar/projects/chipmunks/Demo/ChipmunkDemo.c:473
Original comment by wael.elo...@gmail.com
on 15 Aug 2010 at 4:54
Oh. I was thinking glib. I suppose glibc is a bit different.
I'm not quite sure what is going on there. My best guess is that I've
introduced a double free somehow. I haven't had any problems under my Ubuntu
VM, but it's not exactly up to date. I'll try running it with guard malloc.
Original comment by slemb...@gmail.com
on 15 Aug 2010 at 5:28
Ah. Yup, that did it. I was accessing freshly freed memory, so the bug wouldn't
have shown up very often.
The demo removed the objects like this:
cpSpaceRemoveBody(space, shape->body);
cpBodyFree(shape->body);
cpSpaceRemoveShape(space, shape);
cpShapeFree(shape);
When it should have done this:
cpSpaceRemoveBody(space, shape->body);
cpSpaceRemoveShape(space, shape);
cpBodyFree(shape->body);
cpShapeFree(shape);
When the space attempted to remove the shape from the space, it dereferenced
the body pointer and crashed. I'm not sure if this explains the stack trace you
posted though.
Original comment by slemb...@gmail.com
on 15 Aug 2010 at 5:44
I committed the code to trunk. Could you check that out and verify?
http://code.google.com/p/chipmunk-physics/source/checkout
Original comment by slemb...@gmail.com
on 15 Aug 2010 at 5:54
yep, updated and rebuilt, it's working like charm, thanks :)
Original comment by wael.elo...@gmail.com
on 15 Aug 2010 at 6:36
Original comment by slemb...@gmail.com
on 15 Aug 2010 at 6:54
Original issue reported on code.google.com by
wael.elo...@gmail.com
on 15 Aug 2010 at 2:46