Skip to content

fix: Fix lock order inversion / deadlock (backport #1010) - #1015

Merged
ahcorde merged 2 commits into
humblefrom
mergify/bp/humble/pr-1010
Jul 20, 2026
Merged

fix: Fix lock order inversion / deadlock (backport #1010)#1015
ahcorde merged 2 commits into
humblefrom
mergify/bp/humble/pr-1010

Conversation

@mergify

@mergify mergify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Description

Lyrical backport of #1005


This is an automatic backport of pull request #1010 done by [Mergify](https://mergify.com).

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)
@mergify

mergify Bot commented Jul 20, 2026

Copy link
Copy Markdown
Author

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@ahcorde
ahcorde merged commit b32a97f into humble Jul 20, 2026
5 checks passed
@ahcorde
ahcorde deleted the mergify/bp/humble/pr-1010 branch July 20, 2026 11:04
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants