Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Citadel: backport fix for dartsim segfaults #564

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions dartsim/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,31 @@ class Plugin :
public virtual ShapeFeatures,
public virtual SimulationFeatures { };

namespace {

// This is done as a partial fix for
// https://github.com/gazebosim/gz-physics/issues/442. The issue seems like the
// destructors for the concrete collision detectors get unloaded and deleted
// from memory before the destructors run. When it's time to actually call the
// destructors, a segfault is generated.
//
// It's not clear why the destructors are deleted prematurely. It might be a
// compiler optimization in new compiler versions.
//
// The solution here is to call the `unregisterAllCreators` function from the
// plugins translation unit in the hopes that it will force the compiler to keep
// the destructors.
struct UnregisterCollisionDetectors
{
~UnregisterCollisionDetectors()
{
dart::collision::CollisionDetector::getFactory()->unregisterAllCreators();
}
};

UnregisterCollisionDetectors unregisterAtUnload;
}

IGN_PHYSICS_ADD_PLUGIN(Plugin, FeaturePolicy3d, DartsimFeatures)

}
Expand Down
Loading