This repository was archived by the owner on May 31, 2025. It is now read-only.
Fix for deadlock issue 1980#2121
Merged
jacobperron merged 2 commits intoros:noetic-develfrom Mar 11, 2021
Merged
Conversation
This unit test fails until we can remove callbacks that are being executed.
This fixes a potential deadlock when a timer is being removed that's also being executed.
fujitatomoya
approved these changes
Jan 26, 2021
Contributor
fujitatomoya
left a comment
There was a problem hiding this comment.
makes sense to me. I also confirmed that this PR fixes the deadlock problem introduced here.
Contributor
Author
|
@fujitatomoya , is there anything else I can do to help get this issue merged and resolved? |
Contributor
|
@jacobperron @mjcarroll @sloretz friendly ping. |
jacobperron
approved these changes
Mar 11, 2021
Contributor
jacobperron
left a comment
There was a problem hiding this comment.
The fix looks good to me, thanks!
Also, thank you for the reproduction and unit test 🙇
jacobperron
pushed a commit
that referenced
this pull request
Apr 6, 2021
* Add unit test for removing a callback that's being executed. This unit test fails until we can remove callbacks that are being executed. * Use the marked_for_removal flag if the callback is being executed. This fixes a potential deadlock when a timer is being removed that's also being executed.
This was referenced Sep 28, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
We encountered the issue sketched in #1980 in a production system last week.
To understand the issue at hand I've made a minimal-non-working example here. Looking at the source code it seems that the callback queue is actually at fault, not the timer code. The
removeByIDdeadlocks when a callback by that id is currently being executed.The first commit introduces a unit test that demonstrates this deadlock in a unit test.
The second commit is the proposed fix for this problem. We try to obtain the lock, if we fail to obtain the lock we defer removal until the next callback queue cycle using the already existing
marked_for_removalboolean.FYI @guillaumeautran , @mikepurvis , @jasonimercer