Skip to content

Fix race condition on shutdown in try_discover_source()#143

Open
MarqRazz wants to merge 1 commit intoros-tooling:rollingfrom
MarqRazz:fix_shutdown
Open

Fix race condition on shutdown in try_discover_source()#143
MarqRazz wants to merge 1 commit intoros-tooling:rollingfrom
MarqRazz:fix_shutdown

Conversation

@MarqRazz
Copy link

@MarqRazz MarqRazz commented Mar 9, 2026

In ros2_control we have been having issues with topic_tools/relay not playing nice with SIGINT and failing tests. RelayNode creates a discovery_timer_ that fires every 100ms and calls make_subscribe_unsubscribe_decisions() → try_discover_source() → get_publishers_info_by_topic(). When SIGINT is received, rclcpp::shutdown() invalidates the context, but the timer can still fire and call get_publishers_info_by_topic on the now-invalid context, throwing an uncaught exception.

This PR adds a guard to check for the node shutting down and returns early so the exception is not thrown.

Signed-off-by: MarqRazz <marq.razz@gmail.com>
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.

1 participant