ros2 / rclcpp

rclcpp (ROS Client Library for C++)
Apache License 2.0
514 stars 410 forks source link

LifecycleNode shutdown on dtor only with valid context. #2545

Closed fujitatomoya closed 1 month ago

fujitatomoya commented 1 month ago

https://github.com/ros2/rclcpp/pull/2528 generates the following error when the context is gracefully shutdown. (e.g deferred signal handler of rclcpp.)

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run lifecycle lifecycle_talker
^C[INFO] [1717052032.575390927] [rclcpp]: signal_handler(signum=2)
[ERROR] [1717052032.577706294] [lc_talker]: Unable to start transition 5 from current state shuttingdown: Could not publish transition: publisher's context is invalid, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/publisher.c:423, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl_lifecycle/src/rcl_lifecycle.c:368
[WARN] [1717052032.577764887] [rclcpp_lifecycle]: Shutdown error in destruction of LifecycleNode: final state(unconfigured)

this is because the shutdown in the dtor is called but failed to publish the transition since the context is not valid.

i thought of a couple of things, but at this moment, i would like to label it with TODO.

This also addresses https://github.com/ros2/rclcpp/issues/2547 (Nav2 CI finds this behavior)

fujitatomoya commented 1 month ago

@mjcarroll @clalancette can you take a look at this?

fujitatomoya commented 1 month ago

CI:

fujitatomoya commented 1 month ago

CI is green, i will go ahead to merge this.