Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rclcpp_action std::runtime_error when killing action server #2757

Open
fafux opened this issue Feb 26, 2025 · 2 comments
Open

rclcpp_action std::runtime_error when killing action server #2757

fafux opened this issue Feb 26, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@fafux
Copy link

fafux commented Feb 26, 2025

Hi, I am working on Ubuntu 24.04 with ROS2 jazzy.
I followed the tutorials on how to "Writing an action server and client (C++)". I launched the server and then the client as written in the tutorial. If I send a SIGINT to the server while the action is executing (^C) I get an std::runtime_error specifically:

[INFO] [1740584812.433644455] [rclcpp]: signal_handler(signum=2)
terminate called after throwing an instance of 'std::runtime_error'
  what():  Asked to publish result for goal that does not exist

I think this is a bug. The runtime error is thrown before rclcpp::shutdown() is called. As far as I know the server should send a notification to the client that the goal was canceled or aborted, call rclcpp::shutdown(), and finish cleanly. The problem is that, with this bug, the resources are not released.

@sloretz
Copy link
Contributor

sloretz commented Mar 6, 2025

Just adding the location of the exception:

throw std::runtime_error("Asked to publish result for goal that does not exist");

@fujitatomoya
Copy link
Collaborator

about the exception on action server, i think you met the racy condition. I cannot reproduce this issue though.

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run action_tutorials_cpp fibonacci_action_server
[INFO] [1741309035.485585161] [fibonacci_action_server]: Received goal request with order 10
[INFO] [1741309035.486094219] [fibonacci_action_server]: Executing goal
[INFO] [1741309035.486319267] [fibonacci_action_server]: Publish feedback
[INFO] [1741309036.486456961] [fibonacci_action_server]: Publish feedback
^C[INFO] [1741309037.169525708] [rclcpp]: signal_handler(signum=2)
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run action_tutorials_cpp fibonacci_action_server
[INFO] [1741309042.508744397] [fibonacci_action_server]: Received goal request with order 10
[INFO] [1741309042.509333889] [fibonacci_action_server]: Executing goal
[INFO] [1741309042.509530099] [fibonacci_action_server]: Publish feedback
[INFO] [1741309043.509735177] [fibonacci_action_server]: Publish feedback
^C[INFO] [1741309044.408719362] [rclcpp]: signal_handler(signum=2)
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run action_tutorials_cpp fibonacci_action_server
[INFO] [1741309049.774068952] [fibonacci_action_server]: Received goal request with order 10
[INFO] [1741309049.776226357] [fibonacci_action_server]: Executing goal
[INFO] [1741309049.777100021] [fibonacci_action_server]: Publish feedback
[INFO] [1741309050.776877790] [fibonacci_action_server]: Publish feedback
^C[INFO] [1741309051.480142554] [rclcpp]: signal_handler(signum=2)

The runtime error is thrown before rclcpp::shutdown() is called.

i think Context::shutdown() is called by deferred signal handler when the SIGINT comes in, it shuts down all the context gracefully.

As far as I know the server should send a notification to the client that the goal was canceled or aborted

this seems like a bug, unexpected behavior.
action client is waiting for the result, and action server actually tries to publish action_msgs::msg::GoalStatus::STATUS_CANCELED during destruction.

// Cancel goal if handle was allowed to destruct without reaching a terminal state
if (try_canceling()) {
auto null_result = std::make_shared<typename ActionT::Impl::GetResultService::Response>();
null_result->status = action_msgs::msg::GoalStatus::STATUS_CANCELED;
on_terminal_state_(uuid_, null_result);
}

@fujitatomoya fujitatomoya added the bug Something isn't working label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants