Page 1 of 1

[SOLVED] Rigidbody in manifold became dangling pointer.

Posted: Mon Feb 21, 2022 7:44 am
by douya_5200
When I applied the multi-threaded version of bullet. I get crashes in addManifoldsToIslands() funciton.
where the m_body0 or m_body1 in the manifold within the loop sometimes are dangling pointer,
causing unexpected data and crashes.
It happens almost every time.
I used to check for wrong data and ignored it but then it brought other unexpected problems.

The assert hit is the btAssert(id < m_lookupIslandFromId.size()); where the id is the islandTag of the corrupted rigidbody.

Anyone has any ideas? Thanks!


Edit: When I used to ignore this problem and just check for null island, it causes other unexpected strange problems (solved stability problem but the efficiency seemed problematic) which just do not appear right for me. I want to get to the root of this problem which leads me to this question. :|

Re: Rigidbody in manifold became dangling pointer.

Posted: Mon Feb 28, 2022 7:35 am
by douya_5200
I have identified the problem:
Calling singleTimeCallback ContactTest of the collisionworld would cause this problem.
I'm still trying to find what exactly went wrong. :C

Re: Rigidbody in manifold became dangling pointer.

Posted: Mon Feb 28, 2022 11:40 am
by douya_5200
Hey , everyone:

I've figured out how to solve this problem and I think it's indeed a bug of Bullet.

It's caused by btCollisionDispatcherMt::releaseManifold() being called when the m_batchUpdating boolean is true. (when collision algorithm used by contactTest deconstructs, it calls dispatcher->releaseManifold() )

This will cause the manifold not being properly released, then it's reused for manifold pool allocation and results in corrupted data.

The solution would be to store the manifold into a container in releaseManifold() when batch updating, then remove it after the batchUpdating finished in the next dispatchCollisionPairs() function.