TransformListener hangs waiting for worker thread to join
@clalancette is already working on this.
Since Oct 11, 2018.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.