-
Notifications
You must be signed in to change notification settings - Fork 487
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
Protect DepthCameraPlugin globals with a mutex #2949
Protect DepthCameraPlugin globals with a mutex #2949
Conversation
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Thanks a lot for working on this! It would simplify drastically running Gazebo-based tests. |
@jacobperron I don't have write access here, so please merge when you think this is ready. The PR checkers failures doesn't seem related. |
I don't consider myself a maintainer, so I'll leave it up to @scpeters (or someone else). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to reproduce the failure using pc_pipe on 18.04 and this fixes it. Thanks!
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
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.