Skip to content

[23923] Fix RTPSParticipantAttributes internal data races (backport #6370)#6388

Merged
MiguelCompany merged 2 commits into
3.2.xfrom
mergify/bp/3.2.x/pr-6370
Jun 1, 2026
Merged

[23923] Fix RTPSParticipantAttributes internal data races (backport #6370)#6388
MiguelCompany merged 2 commits into
3.2.xfrom
mergify/bp/3.2.x/pr-6370

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented May 6, 2026

Description

This PR solves a bunch of data races caused by the not-thread-safe access to RTPSParticipantAttributes via its main getter get_attributes(). This method returns a const reference to the object, which can be concurrently modified from other functions like update_attributes() causing a read-write access data race.

The proposed fix should modify the original method to return a copy of the class attribute with the mutex locked, making the access safe. However, this would imply an API break. Thus, a new method has been created to be used internally, leaving the get_attributes() method untouched and marked to be fixed in the next major release.

Related PR:

@Mergifyio backport 3.4.x 3.2.x 2.14.x

Contributor Checklist

  • Commit messages follow the project guidelines.

  • The code follows the style guidelines of this project.

  • N/A: 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

  • N/A: 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.

  • N/A 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.

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

@mergify mergify Bot added the conflicts Backport PR wich git cherry pick failed label May 6, 2026
@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented May 6, 2026

Cherry-pick of 7dd4b4d has failed:

On branch mergify/bp/3.2.x/pr-6370
Your branch is up to date with 'origin/3.2.x'.

You are currently cherry-picking commit 7dd4b4d17.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   include/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp
	modified:   include/fastdds/rtps/participant/RTPSParticipant.hpp
	modified:   src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp
	modified:   src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp
	modified:   src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp
	modified:   src/cpp/fastdds/domain/DomainParticipantImpl.cpp
	modified:   src/cpp/rtps/builtin/BuiltinProtocols.cpp
	modified:   src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp
	modified:   src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp
	modified:   src/cpp/rtps/builtin/discovery/participant/PDP.cpp
	modified:   src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp
	modified:   src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp
	modified:   src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp
	modified:   src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp
	modified:   src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp
	modified:   src/cpp/rtps/builtin/discovery/participant/simple/PDPStatelessWriter.cpp
	modified:   src/cpp/rtps/builtin/liveliness/WLP.cpp
	modified:   src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp
	modified:   src/cpp/rtps/flowcontrol/FlowControllerImpl.hpp
	modified:   src/cpp/rtps/participant/RTPSParticipant.cpp
	modified:   src/cpp/rtps/participant/RTPSParticipantImpl.hpp
	modified:   src/cpp/rtps/reader/BaseReader.cpp
	modified:   src/cpp/rtps/reader/StatefulReader.cpp
	modified:   src/cpp/rtps/security/SecurityManager.cpp
	modified:   src/cpp/rtps/security/SecurityManager.h
	modified:   src/cpp/rtps/security/accesscontrol/AccessControl.h
	modified:   src/cpp/rtps/security/authentication/Authentication.h
	modified:   src/cpp/security/accesscontrol/Permissions.cpp
	modified:   src/cpp/security/accesscontrol/Permissions.h
	modified:   src/cpp/security/authentication/PKIDH.cpp
	modified:   src/cpp/security/authentication/PKIDH.h
	modified:   test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp
	modified:   test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.hpp
	modified:   test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.hpp
	modified:   test/mock/rtps/SecurityPluginFactory/rtps/security/MockAccessControlPlugin.h
	modified:   test/mock/rtps/SecurityPluginFactory/rtps/security/MockAuthenticationPlugin.h
	modified:   test/unittest/dds/participant/ParticipantTests.cpp
	modified:   test/unittest/rtps/security/SecurityTests.hpp
	modified:   test/unittest/security/accesscontrol/AccessControlTests.cpp
	modified:   test/unittest/security/authentication/AuthenticationPluginTests.hpp
	modified:   test/unittest/security/authentication/BuiltinPKIDHTests.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   include/fastdds/dds/publisher/DataWriter.hpp
	both modified:   src/cpp/rtps/participant/RTPSParticipantImpl.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@MiguelCompany MiguelCompany added this to the v3.2.5 milestone May 6, 2026
@MiguelCompany
Copy link
Copy Markdown
Member

@cferreiragonz Could you please fix the conflicts here?

* Refs #23923: Take mutex in getter and env file callback

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23923: Only update mutable attributes

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23923: Copy attributes in getter

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23923: Undo copy attributes

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23923: Avoid calling get_attributes in SecurityManager constructor

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23923: Copy attributes

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23923: Protect missing cases

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Create new method to avoid API break

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Doxygen & TODO in next major

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Copy method in RTPSParticipant

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Mock and tests changes

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Revision

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Add missing mutable attribute

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Create const copy

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Uncrustify

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Spelling

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Split const and mutable RTPSParticipantAttributes

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Review - Fix Mutable & Constant attributes

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Review - Apply methods and composition of BuiltinAttributes

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Review - Update Tests

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Review - Add ConstantDiscoverySettings

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Solve using statement visibility

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Uncrustify

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Store constant attributes set at 'setup_' methods

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Init const attributes and update later

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

* Refs #23923: Review - Improve doxygen

Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>

---------

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
Co-authored-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit 7dd4b4d)

# Conflicts:
#	include/fastdds/dds/publisher/DataWriter.hpp
#	src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
@cferreiragonz cferreiragonz force-pushed the mergify/bp/3.2.x/pr-6370 branch from 552b3d6 to 65596f8 Compare June 1, 2026 07:12
@cferreiragonz cferreiragonz added ci-pending PR which CI is running and removed conflicts Backport PR wich git cherry pick failed labels Jun 1, 2026
@cferreiragonz cferreiragonz self-requested a review June 1, 2026 07:13
@MiguelCompany MiguelCompany merged commit 82bfda2 into 3.2.x Jun 1, 2026
27 of 29 checks passed
@MiguelCompany MiguelCompany deleted the mergify/bp/3.2.x/pr-6370 branch June 1, 2026 14:19
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.

2 participants