adding and removing runtime collisions cause crash

ghiboz
Posts: 11
Joined: Mon Oct 12, 2009 11:47 am

adding and removing runtime collisions cause crash

Post by ghiboz »

hi all!
I have a strange question to fix:
I'm making a racing game, and at the moment my car is a compound made by a convex hull and 4 cylinders
everything works fine, but when I add and remove runtime some rigidbodies, happens that the compound is not yet a compound..
I try to explain:
it assert in this location:
https://github.com/bulletphysics/bullet ... m.cpp#L221
and if I don't add/remove rigidbodies, it never assert in this point..

my question is: maybe happens something wrong when I remove the rigidbody? for example, is too near to the car and the remove action will cause some break to my compound?

I'm a bit in trouble to debug this, 'cause if I run the game in debug, it's slow and doesn't happen, otherwise in release that happens, is not possible debug the issue

thanks in advance
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: adding and removing runtime collisions cause crash

Post by drleviathan »

A question for you: Where exactly in the flow of the game loop are you adding/removing RigidBodies?

If you're doing it in a callback deep inside the stepSimulation() context then I could see how you might end up with dangling or reallocated pointers when resolving collisions. In other words: if broadphase overlaps have already been computed for that step and you remove a RigidBody out from under that list before all collisions are resolved, then I would expect you to suffer.

If you perform all of your RigidBody add/removes outside the stepSimulation() then... that would be a mystery.
ghiboz
Posts: 11
Joined: Mon Oct 12, 2009 11:47 am

Re: adding and removing runtime collisions cause crash

Post by ghiboz »

thank you! I made my `localStepSimulation` called instead `stepSimulation` in my custom `World` class
and the removing/adding is performed just before exiting the `localStepSimulation` function
ghiboz
Posts: 11
Joined: Mon Oct 12, 2009 11:47 am

Re: adding and removing runtime collisions cause crash

Post by ghiboz »

here is the issue I reached to get in debug mode:
Image
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: adding and removing runtime collisions cause crash

Post by drleviathan »

Are you saying: you made changes and now you crash in btDbvtBroadphase::destroyProxy()?

Or are you saying: you were always properly removing the bodies outside of the stepSimulation() context and... now you also see crashes in btDbvtBroadphase::destroyProxy()?

In either case, the mystery deepens. I wouldn't expect crashes there unless something very strange were going on such as (a) you're using some very old buggy version of Bullet (BTW, what version are you using?) (b) memory corruption with delayed consequences or (c) you've found a real and heretofore undiscovered bug in the btDbvtBroadphase implementation (I would consider this option "unlikely, but possible").

Alas, I don't think you have supplied enough info for these forums to remotely debug your problem, and I'm not sure what the minimum set of required info would be, short of full source code and the an good repro recipe. It may be you need to level up your C++ debugging skills but that subject matter is broad and is perhaps outside the scope of these forums.

Good luck.