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
ensure thread safety in clear octomap #2500
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2500 +/- ##
==========================================
- Coverage 60.26% 60.21% -0.04%
==========================================
Files 351 351
Lines 26476 26485 +9
==========================================
- Hits 15952 15945 -7
- Misses 10524 10540 +16
Continue to review full report at Codecov.
|
@felixvd friendly ping as you were the last one to touch this code |
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.
Looks good to me. Awaits a second review.
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.
My bad or introducing the bug. LGTM. Thanks for the fix of UPDATE_GEOMETRY, too.
Will merge after you decide about the proposed comment. I'm good either way.
else | ||
{ | ||
ROS_WARN_NAMED(LOGNAME, "Unable to clear octomap since no octomap monitor has been initialized"); | ||
boost::unique_lock<boost::shared_mutex> ulock(scene_update_mutex_); |
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.
It wasn't hard to figure out how this works, but I had to think for a second because I don't use mutexes a lot. Do you want to add a comment to the effect of // Lock scene using mutex before removing the octomap. Lock expires after the code block
for the less familiar? I'm on the fence.
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 should probably add a comment about the extra brackets that are there so that the scoped lock gets lifted before notifying consumers (triggerSceneUpdateEvent
) in order to avoid a deadlock ...
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 didn't know that the lock needs to be lifted before that call. How about adding // Lift the scoped lock before calling triggerSceneUpdateEvent to avoid deadlock
at the end of the block?
I'm fine with not adding the other comment because I suppose it's not "nonobvious to a reader who understands C++ well".
moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Felix von Drigalski <FvDrigalski@gmail.com>
Thanks @simonschmeisser . Congratulations on getting pull request number #2500. 🤡 |
It took me a long time to actually find something to fix just so I could get this PR number ... 😉 Thanks for reviewing and merging ... I suspect there's going to be another one as we had crashes in the octree->clear part as well that should be locked by themselves |
The method used UPDATE_SCENE which caused a full scene to be transmitted. But only the octomap is modified, so UPDATE_GEOMETRY suffices. Also add comment about necessary scoping of non-recursive lock.
The method used UPDATE_SCENE which caused a full scene to be transmitted. But only the octomap is modified, so UPDATE_GEOMETRY suffices. Also add comment about necessary scoping of non-recursive lock.
The method used UPDATE_SCENE which caused a full scene to be transmitted. But only the octomap is modified, so UPDATE_GEOMETRY suffices. Also add comment about necessary scoping of non-recursive lock.
Description
As commented in #2320 (comment) I recently encountered some crashes when clearOctomap is being called while some planners still run. Even though that is a weird thing to do, it still shouldn't crash.
Also #2320 uses
UPDATE_SCENE
which causes a full scene to be transmitted whileUPDATE_GEOMETRY
should be sufficient.Checklist