Skip to content

Commit 529bde9

Browse files
committed
workaround for crash on shutdown
Signed-off-by: Ashton Larkin <[email protected]>
1 parent b6a1133 commit 529bde9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/EntityComponentManager.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,21 @@ EntityComponentManager::EntityComponentManager()
285285
}
286286

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

290304
//////////////////////////////////////////////////
291305
size_t EntityComponentManager::EntityCount() const

0 commit comments

Comments
 (0)