rclcpp
rclcpp copied to clipboard
create_timer throws but isn't documented to throw
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
- Create a node, and add a (while/for) loop call that blocks while rclcpp::ok() is true
- Trigger a ctrl+C on the node which now means that rclcpp::ok() is false
- Later in code execution, call create_timer(..
- Observe the timer creation fail and throw
- 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.
If you need a minimum reproducible example, I can help provide one, but I haven't spent the time to write one yet.