fix: Fix lock order inversion / deadlock (backport #1010) - #1015
Merged
Conversation
This fixes a deadlock if a guard condition was triggered while a guard condition was being attached or detached. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> Co-authored-by: Janosch Machowinski <J.Machowinski@cellumation.com> (cherry picked from commit c5c101a)
Author
|
Tick the box to add this pull request to the merge queue (same as
|
Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
ahcorde
approved these changes
Jul 20, 2026
karmanyaahm
added a commit
to innate-inc/rmw_zenoh
that referenced
this pull request
Aug 11, 2026
check_and_attach_condition() ends by writing wait_set_data->triggered = false based on a comment asserting that rmw_wait() holds condition_mutex across the call. That precondition was removed by ros2#1005 (backported to humble as ros2#1015), which deliberately drops the lock around check_and_attach_condition() to avoid the ABBA deadlock in ros2#998. The write is now unsynchronized and races with the notifier paths, which set triggered = true while holding condition_mutex. If a message is delivered after its entity has been attached but before check_and_attach_condition() returns, the trailing write clears the flag, rmw_wait() then evaluates its predicate as false and blocks on the condition variable with data already queued. The reset is redundant in any case: rmw_wait() sets triggered = false under condition_mutex immediately before calling this function. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Lyrical backport of #1005
This is an automatic backport of pull request #1010 done by [Mergify](https://mergify.com).