ros2 / ros2/rclcpp

Executor does not maintain a reference to nodes

Open
#726 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04.2 LTS (Bionic Beaver)
  • Installation type:
    • from source
  • Version or commit hash:
    • 005131dba8d7992d9f93b889d0eb265db663b8c5
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • rclcpp
Steps to reproduce issue

Create a shared pointer to a Node, pass it to SingleThreadedExecutor::add_node. Delete or reset the shared pointer. Spin the executor.

#include "rclcpp/rclcpp.hpp"

int main(int argc, char** argv)
{
  rclcpp::init(argc, argv);

  rclcpp::executors::SingleThreadedExecutor executor;
  executor.add_node(std::make_shared<rclcpp::Node>("Test"));
  executor.spin();
  return 0;
}
Expected behavior

The node should run.

Actual behavior

ROS crashes with an error like:

[ERROR] [rclcpp]: Couldn't add guard_condition to wait set: guard condition implementation is invalid, at /opt/ros/master/src/ros2/rcl/rcl/src/rcl/guard_condition.c:174, at /opt/ros/master/src/ros2/rcl/rcl/src/rcl/wait.c:455
terminate called after throwing an instance of 'std::runtime_error'
  what():  Couldn't fill wait set
Additional information

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 at rclcpp::executors::SingleThreadedExecutor::add_node and reproduce the failure with the shared-pointer example in the issue. Trace how the executor retains the node while the original pointer is reset; done means the node remains usable during spin without the wait-set error or runtime exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.