Skip to content

TransformListener hangs waiting for worker thread to join #73

@ghost

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions