Page 1 of 1

iOS 10 and Chipmunk crash

PostPosted: Tue Sep 20, 2016 3:11 pm
by yomanx
Hi friends,

Sometimes my game crashing with this log:

ZombieBasketball was compiled with optimization - stepping may behave oddly; variables may not be available.

Something like this bug was fixed by slembcke in iOS 9, but now in iOS 10 game started crashing again :?

Re: iOS 10 and Chipmunk crash

PostPosted: Wed Sep 21, 2016 10:02 am
by slembcke
That's odd. It's almost definitely caused by the body being freed before the shape attached to it. Since the shape should be retaining the body, I'm not sure how that's possible though. Especially so since ARC is involved.

The ObjectiveChipmunk memory code is pretty straightforward, maybe 10 lines of code involved, and hasn't changed in (5?) years. I sort of doubt there is anything wrong there. The rest uses ARC, so I doubt there is something wrong there too.

The only other clue there is that it's trying to operate on a static body. Are you creating any static bodies yourself?

Re: iOS 10 and Chipmunk crash

PostPosted: Wed Sep 21, 2016 10:04 am
by slembcke
Another possibility that is more insidious is that you might be accidentally using a body (or CCNode) after it's been freed and somehow causing it to be double released. It's sort of unlikely, but it's possible. Try enabling guard malloc, or zombies. They might shed some light.

Re: iOS 10 and Chipmunk crash

PostPosted: Sat Oct 01, 2016 10:14 pm
by yomanx
after dozens tests:

- Guard malloc does not launch an application on my devices it writes about the missing library, we can start it just on the simulators, but it always crashing
- When we turned ON Zombie Objects, we no longer received this bug crash, just crash when the memory out.

we have thousands static bodies..

gameplay, everything on physics

ps today i did test mode on the level where i had crash with 500+ enemies, unlimited lives, and hundreds of weapon using and not received crash, but when i play 20-40 waves i will have this crash :?

Re: iOS 10 and Chipmunk crash

PostPosted: Sun Oct 02, 2016 11:47 am
by yomanx
Maybe something wrong in our code?
its the moment when the mine touching ground, and then its old body is removed and after 0.25 seconds there is a new static sensor body created.

Re: iOS 10 and Chipmunk crash

PostPosted: Sun Oct 02, 2016 8:09 pm
by slembcke
I don't immediately see anything wrong with that, but maybe there is a race condition? There is nothing preventing another ccPhysicsBegin: method call from happening again after the block is scheduled.

It should still be safe from a memory error though, so I can't explain that. I guess I'd try running it with the Allocations instrument. You can search for the memory address it's crashing on and maybe see if it's being double released somehow. Not quite sure what you'd do with the information though. :-\

Re: iOS 10 and Chipmunk crash

PostPosted: Tue Nov 01, 2016 7:34 pm
by yomanx
after tests we fixed this bug, atm i'am not shure what fixed it.

Code: Select all
bomb.physicsBody = nil;
after bomb detonation or some extra delays..

Re: iOS 10 and Chipmunk crash

PostPosted: Wed Nov 02, 2016 11:51 am
by slembcke
Hmm. It was a mysterious crash for sure. Good that it's working for you now.

Hopefully it wasn't actually bug in Chipmunk with some weird undefined behavior.