Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15341] Protect access to reader listeners #2898

Merged
merged 4 commits into from
Aug 3, 2022

Conversation

MiguelCompany
Copy link
Member

Description

This should fix dataraces involving access to the listener on RTPSReader and DataReaderImpl.

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.
  • N/A Any new/modified methods have been properly documented using Doxygen.
  • Fast DDS test suite has been run locally.
  • Changes are ABI compatible.
  • Changes are API compatible.
  • N/A Documentation builds and tests pass locally.
  • 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.

Reviewer Checklist

  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

Copy link
Contributor

@jsan-rt jsan-rt left a comment

Choose a reason for hiding this comment

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

This should be protected as well.

@@ -1637,6 +1639,8 @@ fastrtps::TopicAttributes DataReaderImpl::topic_attributes() const
DataReaderListener* DataReaderImpl::get_listener_for(
const StatusMask& status)
{
std::lock_guard<std::mutex> _(listener_mutex_);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be best to keep the final return clause outside the scope of this mutex.

@MiguelCompany
Copy link
Member Author

This should be protected as well.

I have mixed feelings about this.
On one hand, I feel like protecting RTPSReader::getListener() should be done.
On the other hand, it is called all throughout the RTPS layer code, and the TSan job does not seem to be complaining. This means there are other protections in place whenever the method is called.

My fear is that taking the reader mutex may add ABBA deadlocks...

@jsan-rt
Copy link
Contributor

jsan-rt commented Aug 2, 2022

I'm of the same mind regarding GetListener. Let's just keep it as is for now.

@MiguelCompany
Copy link
Member Author

@richiprosima Please test this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants