This repository was archived by the owner on Feb 3, 2025. It is now read-only.
Protect DepthCameraPlugin globals with a mutex #2949
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm hunting reasons why gazebo server hangs when shutting down ....
One of the failures mode I found is the following one:
the main thread was taking forever in a
std::map::erase
, which based on the traceback must be one of these two:https://github.com/osrf/gazebo/blob/67c43463c87685b7c9d485a9f8d2e6ac760815b9/plugins/DepthCameraPlugin.cc#L46-L49
there are a few reasons why a
std::map::erase
might take for ever:Also doesn't seem to be the case,
this
should be a valid key at that point.From cppreference:
DepthCameraPlugin
active accessing the maps from different threads.For the second and third case I would actually expect a segfault, but I think that if you're unlucky enough it can take long for that to happen (reading from an invalid pointer is not a segfault).
When I tried to reproduce from source I always hit a different failure mode (a deadlock) and not this one, so I cannot confirm the exact reason of the bug.
Just in case, this PR fixes both the second and third reasons above: don't use an iterator for erasing, protect the globals with a mutex.