API footgun: shared_ptr to timer, ambiguous reset

Open
#3,140 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
cpp
Domain
api

Research direction

Start by reviewing the rclcpp::TimerBase::SharedPtr usage with create_wall_timer and the competing timer->reset() and timer.reset() calls shown in the reproduction. Determine whether an explicit timer-restart API is appropriate, then define the expected behavior and add coverage for restarting versus destroying the timer.

Written by the indexing model from the issue text.

Description

more-information-needed
Generated by Generative AI

No response

Operating System:

Linux JCAPC214 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux

ROS version or commit hash:

humble, rolling

RMW implementation (if applicable):

No response

RMW Configuration (if applicable):

No response

Client library (if applicable):

rclcpp

'ros2 doctor --report' output

No response

Steps to reproduce issue
rclcpp::TimerBase::SharedPtr timer =
  node->create_wall_timer(1s,  {
    RCLCPP_INFO(rclcpp::get_logger("test"), "tick");
  });

// Intended: restart the timer
timer->reset();

// Accidental change during refactor:
timer.reset();  // Timer is destroyed instead
Expected behavior

Likely requires a refactor to the api to make the reset_timer explicit and not collide with the pointer

Actual behavior

Your pointer is reset and needs to be reconstructed

Additional information

No response

Dominant language
C++
Stars
829
Forks
587
Avg merge
4d 6h
Merged PRs (30d)
30

Getting set up

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.

More from ros2/rclcpp

All issues in ros2/rclcpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.