-
Notifications
You must be signed in to change notification settings - Fork 522
Open
Labels
Description
Bug report
Required Info:
- Operating System: Ubuntu 20.04
- Installation type: Binaries
- Version or commit hash: 5.0.0-1focal.20201007.211227
- DDS implementation: Fast DDS
- Client library (if applicable): rclcpp
Steps to reproduce issue
TEST(Foo, bar) {
auto node = std::make_shared<rclcpp::Node>("test");
auto executor = std::make_shared<rclcpp::executors::SingleThreadedExecutor>();
executor->add_node(node);
auto executor_spin_future = std::async(
std::launch::async, [&executor]() -> void {
executor->spin();
});
// std::this_thread::sleep_for(50ms);
executor->cancel();
}
Expected behavior
That the test ends.
Actual behavior
Very frequently, the test hangs on the future destruction, waiting for thread join();
Because the thread is stuck on executor->spin() (wait_for_work exactly)
Additional information
Uncommenting the sleep_for fixes the issue on my machine, so there seems to be a race condition.
In our use case, we have test than end faster than that time and trigger this issue, we can add the sleep as a workaround but it's ugly: https://github.com/ros-controls/ros2_control/pull/234/files/833b1661209cc12a9d6f9ef45c87f4072e641aa7#diff-28c9aa0318c48cffb66c294bbf17394b6f9295bb8b9fb83d2cac539699f7e354R130
Reactions are currently unavailable