Crash in contactSetEql

Official forum for the Chipmunk2D Physics Library.
Post Reply
ggobieski
Posts: 2
Joined: Sun Jul 03, 2011 8:47 am
Contact:

Crash in contactSetEql

Post by ggobieski »

Hi all,
I need some help figuring out why my iPhone app occasionally crashes (Exc_Bad_Access) when running the contactSetEql routine. More specifically it seems to be this line:

return ((a == arb->private_a && b == arb->private_b) || (b == arb->private_a && a == arb->private_b));

that causes the crash and the Exc_Bad_Access. Below is pseudo code for what I am doing within my app.

1. Run two loops that add active and static shapes to the space (shapes and bodies are adding on top of each others)
2. Recycle the active shapes
3. Place static shapes where user touches --> rehash space

I want to make it clear that the relocation of the static and active shapes is not the problem. It crashes only on occasion during the startup.

Thanks for any help or suggestions!
User avatar
slembcke
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Crash in contactSetEql

Post by slembcke »

I assume you are using Chipmunk 5.3.4?
2. Recycle the active shapes
This sounds like you are trying to do something clever that triggers some undefined behavior in Chipmunk. Are you swapping the body for a shape while the body is still added to the shape maybe?

It would be helpful if you could provide some more information about the crash. Is arb NULL or a dangling pointer? Could you post some of the code?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
ggobieski
Posts: 2
Joined: Sun Jul 03, 2011 8:47 am
Contact:

Re: Crash in contactSetEql

Post by ggobieski »

Since I have never had this error when running the application in the simulator I decided to restore the iPad I was running it on and sure enough the error went away. Seems it was a bug in the operating system and the way I was closing the application. Thanks for your help.

Tip: To avoid this error and other weird errors always stop the application through Xcode. Do not close the application on the iOS Device with the home button.
User avatar
slembcke
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Crash in contactSetEql

Post by slembcke »

It's probably not an OS bug actually. Memory bugs are very finicky and not strictly reproducible. Restarting your iPad might change the memory locations that your app is given and cause it to crash differently or not at all. Try running it with guard malloc enabled. It will run super slow, but will crash immediately when you try to access a bad pointer instead of working fine sometimes and not others.

If it was happening when you close the application it might be because you were freeing the space and then somewhere else it would call cpSpaceStep() again. I was wondering how those arbiter pointers could be bad as they are strictly managed by the space.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests