Skip to content

Commit

Permalink
workaround for crash on shutdown
Browse files Browse the repository at this point in the history
Signed-off-by: Ashton Larkin <[email protected]>
  • Loading branch information
adlarkin committed Mar 15, 2022
1 parent b6a1133 commit 529bde9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/EntityComponentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,21 @@ EntityComponentManager::EntityComponentManager()
}

//////////////////////////////////////////////////
EntityComponentManager::~EntityComponentManager() = default;
EntityComponentManager::~EntityComponentManager()
{
// Views created in plugins have their destructor defined in the plugin that
// created the view. If a plugin has been unloaded early, trying to delete
// these views when destroying the ECM causes a segfault.
// To avoid a crash on shutdown for now, unique pointers to views are released
// so that view's destructors are not automatically called when the ECM is
// destroyed.
// (see https://github.com/ignitionrobotics/ign-gazebo/issues/1158
// for more info about why this may happen)
// TODO(adlarkin) find a better way to resolve this issue; possible solution
// in https://github.com/ignitionrobotics/ign-gazebo/pull/1317
for (auto &v : this->dataPtr->views)
v.second.first.release();
}

//////////////////////////////////////////////////
size_t EntityComponentManager::EntityCount() const
Expand Down

0 comments on commit 529bde9

Please sign in to comment.