cpPostStepCallBack is murdering me

Official forum for the Chipmunk2D Physics Library.
Post Reply
rocity
Posts: 7
Joined: Thu Dec 01, 2011 2:10 pm
Contact:

cpPostStepCallBack is murdering me

Post by rocity »

My goodness, I'm sure a million forum topics on this have been created, but I can't find any that address the specific problem I'm having.

In my game, I am detecting a collision between two collision types. When this occurs, my collision handler tells one of the objects to destroy itself, and in its destruction method I have a cpSpaceAddPostStepCallback call to remove the object's physics objects. Shortly thereafter, the callback is called and the space is locked, so it says to use a post step callback...which I am.

My physics post step callback is called removePhysicsCallBack

My runtime stack looks like this:
#0 0x921c89c6 in __pthread_kill ()
#1 0x9012df78 in pthread_kill ()
#2 0x9011ebdd in abort ()
#3 0x00064c98 in cpMessage at /<redacted>/chipmunk.c:44
#4 0x0007c5b7 in cpSpaceRemoveBody ()
#5 0x0003561d in removePhysicsCallBack ()
#6 0x00081e34 in postStepCallbackSetIter ()
#7 0x00076b67 in cpHashSetEach ()
#8 0x00081683 in cpSpaceStep at /Users/<redacted>/Chipmunk/src/cpSpaceStep.c:398
rocity
Posts: 7
Joined: Thu Dec 01, 2011 2:10 pm
Contact:

Re: cpPostStepCallBack is murdering me

Post by rocity »

Since space->locked-- is being called and space->locked is still 1, I suppose that means I'm doing something I shouldn't be...?
rocity
Posts: 7
Joined: Thu Dec 01, 2011 2:10 pm
Contact:

Re: cpPostStepCallBack is murdering me

Post by rocity »

Is it because I am adding the callback in a class other than the class that handles the collisions? It seems like the callbacks are being called before the collision can finish being handled.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpPostStepCallBack is murdering me

Post by slembcke »

I don't know of any bug that would cause the lock count to become unbalanced. However, somebody did run into this issue before because of NSAssertions. Double check the console to make sure that there aren't any assertions happening.

NSAssertion can be set up to behave a number of ways. One of them is to log the message and then throw an exception that is caught by the event loop. The event loop displays the message and continues on it's merry way. The other person that had your issue was triggering an NSAssertion inside of a callback somewhere causing it to never unlock the space again. They didn't notice that there was an assertion message being thrown because it wasn't crashing the program.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
rocity
Posts: 7
Joined: Thu Dec 01, 2011 2:10 pm
Contact:

Re: cpPostStepCallBack is murdering me

Post by rocity »

unfortunately, there's no failed assertions. i have an array of objects and these objects have a method called getRidOfObject, which has a cpSpaceAddPostStepCallback in it to get rid of the object's physics objects. what i'm doing is running a method that gets rid of all the objects, so something like for(Object *object in layer.myobjects) {[object getRidOfObject];} the first object in the array is gotten rid of, but the 2nd object causes chipmunk some issue. any ideas?
Post Reply

Who is online

Users browsing this forum: Heise IT-Markt [Crawler] and 20 guests