Skip to content

Track all waitables that are currently in a wait set #207

Closed
@nnmm

Description

@nnmm

During some refactoring to remove SubscriptionBase, I noticed that the wait set currently violates the unsafe code principles: Safe code can cause undefined behavior by adding the same item to multiple wait sets in different threads and waiting on them. From the rcl docs for rcl_wait():

This function is thread-safe for unique wait sets with unique contents.
This function cannot operate on the same wait set in multiple threads, and the wait sets may not share content.
For example, calling rcl_wait() in two threads on two different wait sets that both contain a single, shared guard condition is undefined behavior.

We need to either make all functions that end up calling rcl_wait() unsafe, like rclrs::spin(), or we need to guarantee that wait sets do not share contents. The latter could be done by having a global list of waitables that are currently in a wait set, and would be my favored approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions