rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

create_timer throws but isn't documented to throw

Open Ryanf55 opened this issue 9 months ago • 5 comments

Operating System:

Ubuntu 24

ROS version or commit hash:

Jazzy

RMW implementation (if applicable):

fastrtps

RMW Configuration (if applicable):

N/A

Client library (if applicable):

rclcpp

'ros2 doctor --report' output

N/A - it's proprietary

Steps to reproduce issue

  1. Create a node, and add a (while/for) loop call that blocks while rclcpp::ok() is true
  2. Trigger a ctrl+C on the node which now means that rclcpp::ok() is false
  3. Later in code execution, call create_timer(..
  4. Observe the timer creation fail and throw
  5. Observe a non-zero exit code from the node

Expected behavior

If exceptions are throw, they are documented in the header. Alternatively, create_timer could return nullptr and catch the exception.

Actual behavior

This exception is not documented

Additional information

[Thread 0x7fff5e7fc6c0 (LWP 1030613) exited]
terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
  what():  Couldn't initialize rcl timer handle: the given context is not valid, either rcl_init() was not called or rcl_shutdown() was called., at ./src/rcl/guard_condition.c:67

Thread 1 "MyNode" received signal SIGABRT, Aborted.

Here's the backtrace.

Image

If you need a minimum reproducible example, I can help provide one, but I haven't spent the time to write one yet.

Ryanf55 avatar Apr 01 '25 21:04 Ryanf55