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

Race conditions when accessing data #249

Open
3 tasks
Yadunund opened this issue Jul 25, 2024 · 0 comments
Open
3 tasks

Race conditions when accessing data #249

Yadunund opened this issue Jul 25, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Yadunund
Copy link
Member

The current implementation suffers from data races between threads that access the same data, eg. rmw_publisher_data_t. There are essentially two classes of races:

  1. One thread destructing the data object and another accessing is modifying it.
  2. Two or more threads are modifying the data object.

Proposal to address the issue

  • Update all data classes to rely on getters and setters to access members while locking mutexes.
  • The type erased data fields in rmw types, eg rmw_publisher_t->data will store the raw pointer to the RMW context. The assumption here is that the context will always be valid if an RMW entity is valid
  • The rmw_context_impl_s class will store sets/vectors of rmw_x_data_t objects of the various RMW entities (publishers, subs, clients, servers, etc). Two or more threads will lock the same mutex in the rmw_context_impl_s while accessing/modifying these objects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant