Skip to content

[23847] Protect DataReaderInstance alive_writers attribute#6123

Merged
MiguelCompany merged 1 commit intomasterfrom
tsan/alive-writers
Nov 6, 2025
Merged

[23847] Protect DataReaderInstance alive_writers attribute#6123
MiguelCompany merged 1 commit intomasterfrom
tsan/alive-writers

Conversation

@juanlofer-eprosima
Copy link
Copy Markdown
Contributor

@juanlofer-eprosima juanlofer-eprosima commented Oct 23, 2025

Description

This PR attempts to solve the data race produced in intraprocess scenario, when a writer sends a message from a thread (which updates its associated instance state in the reader receiving the message: DataReaderImpl::on_new_cache_change_added → DataReaderHistory::update_instance_nts → … → DataReaderInstance::writer_set), while from another thread the instances state of the same reader is also updated without protection (e.g., when destroying a matched writer: DataReaderImpl::update_subscription_matched_status → … → DataReaderInstance::writer_unregister). In the first thread the reader mutex is taken before calling update_instance_nts, the problem is that in the second thread that mutex is never taken.

@Mergifyio backport 3.3.x 3.2.x 2.14.x

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
  • 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.
  • 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.

@juanlofer-eprosima juanlofer-eprosima added this to the v3.4.1 milestone Oct 23, 2025
@juanlofer-eprosima juanlofer-eprosima requested review from richiprosima and removed request for richiprosima October 23, 2025 14:15
@github-actions github-actions bot added the ci-pending PR which CI is running label Oct 23, 2025
@juanlofer-eprosima juanlofer-eprosima marked this pull request as draft October 23, 2025 14:17
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 23, 2025

🧪 CI Insights

Here's what we observed from your CI run for 976ba43.

❌ Job Failures

Pipeline Job Health on master Retries 🔍 CI Insights 📄 Logs
Fast DDS MacOS CI mac-ci / fastdds_test () Unknown 0 View View
Fast DDS Windows CI windows-ci / fastdds_test (RelWithDebInfo, examples), v142 Unknown 0 View View
windows-ci / fastdds_test (RelWithDebInfo, examples), v143 Unknown 0 View View

@juanlofer-eprosima juanlofer-eprosima requested review from richiprosima and removed request for richiprosima October 29, 2025 15:56
@juanlofer-eprosima juanlofer-eprosima requested review from richiprosima and removed request for richiprosima October 30, 2025 13:23
@juanlofer-eprosima juanlofer-eprosima requested review from richiprosima and removed request for richiprosima November 3, 2025 15:46
@juanlofer-eprosima juanlofer-eprosima marked this pull request as ready for review November 4, 2025 13:40
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Copy link
Copy Markdown
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

@MiguelCompany MiguelCompany merged commit 19d6a2b into master Nov 6, 2025
25 of 28 checks passed
@MiguelCompany MiguelCompany deleted the tsan/alive-writers branch November 6, 2025 09:55
@MiguelCompany
Copy link
Copy Markdown
Member

@Mergifyio backport 3.3.x 3.2.x 2.14.x

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 6, 2025

backport 3.3.x 3.2.x 2.14.x

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Nov 6, 2025
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit 19d6a2b)
mergify bot pushed a commit that referenced this pull request Nov 6, 2025
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit 19d6a2b)

# Conflicts:
#	src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp
mergify bot pushed a commit that referenced this pull request Nov 6, 2025
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit 19d6a2b)

# Conflicts:
#	src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp
MiguelCompany pushed a commit that referenced this pull request Nov 7, 2025
(cherry picked from commit 19d6a2b)

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Co-authored-by: juanlofer-eprosima <88179026+juanlofer-eprosima@users.noreply.github.com>
MiguelCompany added a commit that referenced this pull request Nov 7, 2025
* Protect DataReaderInstance alive_writers attribute (#6123)

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit 19d6a2b)

# Conflicts:
#	src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp

* Fix conflicts

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: juanlofer-eprosima <88179026+juanlofer-eprosima@users.noreply.github.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
MiguelCompany added a commit that referenced this pull request Nov 11, 2025
* Protect DataReaderInstance alive_writers attribute (#6123)

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit 19d6a2b)

# Conflicts:
#	src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp

* Fix conflicts

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: juanlofer-eprosima <88179026+juanlofer-eprosima@users.noreply.github.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
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