SMACC2 icon indicating copy to clipboard operation
SMACC2 copied to clipboard

Jazzy: Ctrl+C does not exit (e.g., sm_atomic_node) — please backport Humble SignalDetector shutdown fixes

Open henaiguo opened this issue 1 month ago • 0 comments

Describe the bug On ROS 2 Jazzy, pressing Ctrl+C does not fully exit example nodes (e.g., sm_atomic_node) when built with Release/RelWithDebInfo. The first Ctrl+C triggers rclcpp’s signal handler and SMACC2 logs show state exit/cleanup and SignalDetector::pollingLoop() returning, but the process hangs until a second Ctrl+C or an external kill.

To Reproduce Steps to reproduce the behavior:

  1. Build SMACC2 (branch: jazzy) with colcon.
  2. ros2 run sm_atomic sm_atomic_node
  3. Press Ctrl+C → node does not terminate.

Actual: main loop stops, but the scheduler thread (boost::thread running boost::statechart::fifo_scheduler<>::operator()) keeps running, so the process doesn’t exit. In Release this is very consistent.

It looks like jazzy’s SignalDetector lacks the graceful shutdown behavior that exists on Humble, specifically in:

  • smacc2/include/smacc2/smacc_signal_detector.hpp
  • smacc2/src/smacc2/signal_detector.cpp

The Humble branch registers an on_shutdown callback on the node’s rclcpp Context, and ensures the scheduler is terminated so the thread returns. It also uses context-aware shutdown checks (and avoids spinning while holding the state machine mutex), which prevents deadlocks/hangs on optimized builds.

Request: please sync/backport the Humble fixes into the Jazzy branch (or advise if you’d like a PR). I’m concerned there may be other shutdown/robustness tweaks in Humble that didn’t make it to Jazzy.

henaiguo avatar Nov 08 '25 06:11 henaiguo