Skip to content

[25806] Fix deadlock updating attributes while pairing - #6668

Merged
MiguelCompany merged 1 commit into
masterfrom
bugfix/25806
Dec 4, 2026
Merged

MiguelCompany merged 1 commit into
masterfrom
bugfix/25806

Conversation

@emiliocuestaf

@emiliocuestaf emiliocuestaf commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR addresses a possible deadlock between RTPSParticipantImpl::update_attributes() and the pairing of a new local endpoint:

  • Pairing: holds endpoints_list_mutex shared (for_user_writers / for_user_readers), then takes the PDP mutex in PDP::lookupWriterProxyData to check for matches
  • update_attributes(): holds the PDP mutex, then takes endpoints_list_mutex exclusively to update the locators of endpoints that use the default ones

The fix is for update_attributes() to take endpoints_list_mutex shared. That block only reads the endpoint lists, so an exclusive lock is not needed. The code that takes it exclusively (endpoint creation and removal) never takes the PDP mutex, so the two locks can no longer be taken in opposite orders.

A regression test is added to the RTPS blackbox tests (RTPS.update_attributes_while_pairing_does_not_deadlock), where:

  • It occupies the participant's default unicast port, so every update_attributes() call sees a change in the default locators
  • It pauses the pairing of a local reader inside a writer's matched callback
  • While the pairing is paused, it calls update_attributes()

Without the fix, the test detects the deadlock and exits after 10 s. With the fix, it passes.

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • N/A Any new configuration API has an equivalent XML API (with the corresponding XSD extension)
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • N/A New feature has been added to the versions.md file (if applicable).
  • N/A New feature has been documented/Current behavior is correctly described in the documentation.
  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • If this is a critical bug fix, backports to the critical-only supported branches have been requested.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

* Refs #25806. Add test for deadlock updating attributes while pairing.

Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com>

* Refs #25806. Replace lock_guard with shared_lock to prevent deadlock

Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com>

---------

Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com>
@emiliocuestaf emiliocuestaf added this to the v3.6.4.0 milestone Dec 3, 2026
@github-actions github-actions Bot added the ci-pending PR which CI is running label Dec 3, 2026

@David-LP99 David-LP99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@MiguelCompany
MiguelCompany merged commit 2db8345 into master Dec 4, 2026
47 of 53 checks passed
@MiguelCompany
MiguelCompany deleted the bugfix/25806 branch December 4, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-pending PR which CI is running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants