[SOLVED] Rigidbody in manifold became dangling pointer.

Post Reply
douya_5200
Posts: 10
Joined: Tue Jan 18, 2022 10:29 am
Location: Guangzhou, China

[SOLVED] Rigidbody in manifold became dangling pointer.

Post 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. :|
Attachments
12.png
12.png (88.42 KiB) Viewed 4053 times
Last edited by douya_5200 on Mon Feb 28, 2022 11:48 am, edited 1 time in total.
douya_5200
Posts: 10
Joined: Tue Jan 18, 2022 10:29 am
Location: Guangzhou, China

Re: Rigidbody in manifold became dangling pointer.

Post 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
douya_5200
Posts: 10
Joined: Tue Jan 18, 2022 10:29 am
Location: Guangzhou, China

Re: Rigidbody in manifold became dangling pointer.

Post 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.
Post Reply