Repository navigation
[25806] Fix deadlock updating attributes while pairing - #6668
Merged
Merged
Conversation
* 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>
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
This PR addresses a possible deadlock between
RTPSParticipantImpl::update_attributes()and the pairing of a new local endpoint:endpoints_list_mutexshared (for_user_writers/for_user_readers), then takes the PDP mutex inPDP::lookupWriterProxyDatato check for matchesupdate_attributes(): holds the PDP mutex, then takesendpoints_list_mutexexclusively to update the locators of endpoints that use the default onesThe fix is for
update_attributes()to takeendpoints_list_mutexshared. 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:update_attributes()call sees a change in the default locatorsupdate_attributes()Without the fix, the test detects the deadlock and exits after 10 s. With the fix, it passes.
Contributor Checklist
versions.mdfile (if applicable).Reviewer Checklist