ros2 / ros2/rclcpp

create_timer throws but isn't documented to throw

Open
#2,793 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
805
Forks
564
Avg merge
1d 17h
Merged PRs (30d)
27

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the rclcpp create_timer declarations in their header and reproduce the call after rclcpp shutdown using the reported sequence. Check each relevant overload's documented exceptions; done means the post-shutdown RCLError behavior is documented, unless maintainers decide the requested behavior change should be handled separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.