-
Notifications
You must be signed in to change notification settings - Fork 295
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
Lock views during system PostUpdates #1001
Conversation
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
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've got a few comments/questions for PR reviewers.
Codecov Report
@@ Coverage Diff @@
## main #1001 +/- ##
==========================================
+ Coverage 63.77% 63.80% +0.02%
==========================================
Files 246 246
Lines 19996 20015 +19
==========================================
+ Hits 12753 12771 +18
- Misses 7243 7244 +1
Continue to review full report at Codecov.
|
what's a good way to test this PR? Should I merge these changes with #959 and try cloning lights? |
Yeah, that's what I did! Cloning lights should segfault without these changes. I'd try cloning a light several times with/without these changes to make sure that the race condition is fixed. |
Signed-off-by: Ashton Larkin <ashton@openrobotics.org>
hmm I merged these changes into the
I followed the steps you mentioned in #959:
I don't get the crash if sim is not paused though. |
Oh yeah, so the steps I mentioned about multiple clones/removals while simulation is paused in #959 is actually a separate bug that I don't believe is related to this PR (sorry about the confusion). That seems to be something separate that needs to be fixed, which is why I brought it up, but it has nothing to do with the race condition (at least, I don't think). With this PR, you should have no issues cloning/removing lights while simulation is running, and should have no issues cloning an entity while simulation is paused, as long as you don't remove it and try to re-clone it again while simulation is paused. |
ok I see. I tried the |
Signed-off-by: Ashton Larkin ashton@openrobotics.org
🦟 Bug fix
Fixes a race condition discovered in #959 (comment)
Summary
As a consequence of the changes in #856, new entities aren't added to a view until the view is used, because we need access to the template signature of the view when adding entities to it. This introduces a potential race condition when processing system
PostUpdate
s since systemPostUpdate
s are run in parallel (see #959 (comment) for a more detailed explanation).The fix proposed here is to assign a mutex to every view that exists. Then, when processing system
PostUpdate
s, we lock the view while entities are being added to it. Since every view has its own mutex, this means that different views can still be accessed in parallel duringPostUpdate
calls - the only time blocking may occur is when two systemPostUpdate
s are trying to read from the same view. So, there shouldn't be any major performance hits here.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge