ros2 / ros2/geometry2

TransformListener hangs waiting for worker thread to join

Open
#73 1 comment 0 reactions 1 assignee View on GitHub

@clalancette is already working on this.

Since Oct 11, 2018.

bug
Dominant language
C++
Stars
153
Forks
256
Avg merge
3d 23h
Merged PRs (30d)
14

Description

If a TransformListener object goes out of scope before rclcpp::shutdown is called, it will hang forever in the destructor waiting for the worker thread to join

Bug report

Required Info:

  • Operating System:
    • Ubuntu 16.04
  • Installation type:
    • source
  • Version or commit hash:
    • 0.9.1
  • DDS implementation:
    -Fast-RTPS
  • Client library (if applicable):
Steps to reproduce issue

This example is a bit pathological but shows the issue.

#include <memory>
#include <exception>
#include "rclcpp/rclcpp.hpp"
#include "tf2_ros/transform_listener.h"

int main(int argc, char ** argv)
{
  rclcpp::init(argc, argv);
  try {
    tf2_ros::Buffer tfBuffer;
    tf2_ros::TransformListener tfListener(tfBuffer);
    std::cerr << "Finished construction" << std::endl;
    throw std::runtime_error("blah");
  } catch (...) {
    std::cerr << "caught exception" << std::endl;
  }
  rclcpp::shutdown();

  return 0;
}
Expected behavior

I expect the program to terminate.

Actual behavior

Program hangs trying to unwind the try block

Additional information

The destructor of the TransformListener object calls join on the worker thread. Since nothing tells the worker thread to terminate in this case, the program hangs until someone presses Ctrl-C.

I believe the TransformListener destructor should tell the worker thread to terminate before it calls join

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.