[24604] Fix minor dataraces#6422
Open
ZakariaTalbi wants to merge 17 commits into
Open
Conversation
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
…ith atomic Signed-off-by: Zakaria Talbi Lalmi <zakariatalbi@eprosima.com>
ZakariaTalbi
requested review from
richiprosima
and removed request for
richiprosima
June 16, 2026 09:16
MiguelCompany
requested changes
Jul 20, 2026
MiguelCompany
left a comment
Member
There was a problem hiding this comment.
Apart from my comments below, please check whether changes made in PubSubReader and PubSubWriter also apply to PubSubWriterReader and/or PubSubParticipant
Comment on lines
+70
to
+78
| // TODO: same issue as get_raw_status, reference escapes the lock. | ||
| return mask_; | ||
| } | ||
|
|
||
| const StatusMask& StatusConditionImpl::get_raw_status() const | ||
| { | ||
| std::lock_guard<std::mutex> guard(mutex_); | ||
| // TODO: returning a reference to a mutex-protected member that escapes the lock is a data race. | ||
| // Fix requires changing the return type to StatusMask (by value), which is an API break. |
Member
There was a problem hiding this comment.
Change these into FASTDDS_TODO_BEFORE(4, 0, ...)
|
|
||
| unsigned int get_participants_matched() const | ||
| { | ||
| std::unique_lock<std::mutex> lock(mutexDiscovery_); |
Member
There was a problem hiding this comment.
Suggested change
| std::unique_lock<std::mutex> lock(mutexDiscovery_); | |
| std::lock_guard<std::mutex> lock(mutexDiscovery_); |
Member
There was a problem hiding this comment.
Take the chance to also change it in other places.
|
|
||
| unsigned int get_participants_matched() const | ||
| { | ||
| std::unique_lock<std::mutex> lock(mutexDiscovery_); |
Member
There was a problem hiding this comment.
Suggested change
| std::unique_lock<std::mutex> lock(mutexDiscovery_); | |
| std::lock_guard<std::mutex> lock(mutexDiscovery_); |
|
|
||
| unsigned int get_participants_matched() | ||
| { | ||
| std::unique_lock<std::mutex> lock(mutexDiscovery_); |
Member
There was a problem hiding this comment.
Suggested change
| std::unique_lock<std::mutex> lock(mutexDiscovery_); | |
| std::lock_guard<std::mutex> lock(mutexDiscovery_); |
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
The goal of this PR is to solve some of the minor dataraces that appear when running under the TSAN meta.
LocalReader datarace:
ReaderLocator::local_reader_was being read inintraprocess_heartbeatandintraprocess_deliverywithout holding the writer's mutex, whileReaderLocator::stop()reset it under that same mutex, causing a data race. Fixed by acquiringmp_mutexbefore callinglocal_reader()in both methods.As this was already being reported by TSAN when running the
DDSBasic_WarningOnDelete_Test, no new tests have been added.Contributor Checklist
versions.mdfile (if applicable).Reviewer Checklist