Skip to content

Commit

Permalink
Merge branch 'gz-physics6' into relocbin2
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcarroll authored Aug 28, 2023
2 parents a4d57c4 + 5343ab9 commit b631687
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dartsim/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ class Plugin :
public virtual SimulationFeatures,
public virtual WorldFeatures { };

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;
}

GZ_PHYSICS_ADD_PLUGIN(Plugin, FeaturePolicy3d, DartsimFeatures)

}
Expand Down

0 comments on commit b631687

Please sign in to comment.