You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know Bullet very well so apologies if this doesn't make sense. But, I just fixed a crash-on-exit bug in a program that uses Bullet. The problem turned out to be that a object managing Bullet was using std::shared_ptrs to keep btBroadphaseInterface and btCollisionWorld pointers, among other things. I noticed that the problem was fixed if I explicitly destroyed the btCollisionWorld object instead of letting the shared_ptrs take care of it.
It turns out that during the btCollisionWorld destructor, it makes some dereferences of a broadphase proxy that references the btBroadphaseInterface. However, due to the order of the variables declared in the manager class, the btBroadphaseInterface was getting destroyed first, leading to a segfault during the btCollisionWorld destructor.
I was wondering if an acceptable solution would be for btBroadphaseInterface to remove any proxies that point to it during its destructor? That way there would be no order dependency between their destructors. However, maybe it's impossible, or even wasteful, since it would require a sweep through all broadphase objects just before they are destroyed. Otherwise, any ideas on how such a segfault could be warned against or avoided?
The text was updated successfully, but these errors were encountered:
Yes, it is recommended to explicitly destroy objects in the reverse order of construction, don't use smart pointers etc. Memory in Bullet is managed explicitly in the right order, not in random arbitrary order.
I envy C-API's that make such smart pointer mess-up harder :)
This fixes two tests with segfaults on macOS
* COMMON_TEST_simulation_features_bullet-featherstone: The failure appears to be due to the destruction order of the triangleMeshes and meshesGImpact containers. Per [this] (Should btBroadphaseInterface destructor remove itself from btCollisionObject broadphase proxies? bulletphysics/bullet3#567 (comment)) comment, memory in bullet is sensitive to order of destruction. meshesGImpact objects contain pointers to items contained bytriangleMeshes, so the solution is to ensure meshesGImpact is destructed before triangleMeshes.
* INTEGRATION_DoublePendulum: This is a DART test, but the segfault seems to be related to Bullet. I found that even after removing all the code in DARTDoublePendulum.cc, the segfault still occurs as long as it's linked with libdart-collision-bullet. Since the test doesn't need the bullet collision detector, I've opted to just remove the library from the DART_LIBRARIES variable. I still don't know the root cause though, so this might affect the actual dartsim-plugin library.
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
I don't know Bullet very well so apologies if this doesn't make sense. But, I just fixed a crash-on-exit bug in a program that uses Bullet. The problem turned out to be that a object managing Bullet was using std::shared_ptrs to keep btBroadphaseInterface and btCollisionWorld pointers, among other things. I noticed that the problem was fixed if I explicitly destroyed the btCollisionWorld object instead of letting the shared_ptrs take care of it.
It turns out that during the btCollisionWorld destructor, it makes some dereferences of a broadphase proxy that references the btBroadphaseInterface. However, due to the order of the variables declared in the manager class, the btBroadphaseInterface was getting destroyed first, leading to a segfault during the btCollisionWorld destructor.
I was wondering if an acceptable solution would be for btBroadphaseInterface to remove any proxies that point to it during its destructor? That way there would be no order dependency between their destructors. However, maybe it's impossible, or even wasteful, since it would require a sweep through all broadphase objects just before they are destroyed. Otherwise, any ideas on how such a segfault could be warned against or avoided?
The text was updated successfully, but these errors were encountered: