Skip to content

Race condition in executor when canceling before spin #3172

@skyegalaxy

Description

@skyegalaxy

Generated by Generative AI

No

Operating System:

resolute, in the buildfarm

ROS version or commit hash:

rolling

RMW implementation (if applicable):

No response

RMW Configuration (if applicable):

No response

Client library (if applicable):

rclcpp

'ros2 doctor --report' output

ros2 doctor --report
<COPY OUTPUT HERE>

Steps to reproduce issue

first surfaced in ros-perception/image_common#421

Expected behavior

the executor does not hang indefinitely if cancelled before it spins

Actual behavior

copied from the issue:

TearDown() calls executor->cancel() , setting the executor's internal spinning atomic flag to false .
The background thread subsequently starts executing spin() , which performs spinning.exchange(true) . This unconditionally sets spinning back to true .
The executor enters the spin loop and blocks on wait_for_work() indefinitely, as cancel() has already been called. The thread never joins, causing the test suite to hang.

Additional information

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions