Skip to content

API footgun: shared_ptr to timer, ambiguous reset #3140

Description

@matthews-jca

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions