-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get exception "Resource deadlock avoided" while running TestTimeSource.clock_sleep_until_with_ros_time_basic #1861
Comments
Does this happen with rmw_fastrtps with mainline? |
Also happen after checking. |
Backstrace info based on coredump file |
After checking codes, I find the possible cause In test codes rclcpp/rclcpp/test/rclcpp/test_time_source.cpp Lines 751 to 755 in 80f93d1
NodeState will create a thread (new executor) to run a subscriber to receive clock message. rclcpp/rclcpp/src/rclcpp/time_source.cpp Lines 419 to 433 in 80f93d1
While destroying TimeSource (maybe internal NodeState is being destroyed), above callback is called. So NodeState isn't destroyed while destroying TimeSource. NodeState is handled by new shared_ptr of NodeState from the weak_ptr of NodeState (code is According to coredump info, the problem occurs in callback.
While leaving callback, NodeState will be truly destroyed at this time. While destructing NodeState, the below function will be called. It wants to wait current thread termination. So lead to resource deadlock issue. rclcpp/rclcpp/src/rclcpp/time_source.cpp Lines 437 to 447 in 80f93d1
In order to avoid this issue, we should make sure clock subscriber thread is terminated while destroying TimeSource.
After modification, I re-run test many times (> 60000). This problem doesn't occur. |
@clalancette is refactoring relevant codes. It can fix this issue and it is better solution. So I will close my fixing #1865. |
Bug report
Required Info:
Steps to reproduce issue
Find this issue in CI execution https://build.ros2.org/job/Rpr__rclcpp__ubuntu_focal_amd64/1636/testReport/projectroot.test/rclcpp/test_time_source/
The below steps also can reproduce this problem
Expected behavior
No exception
Actual behavior
Unexpected exception occurs
The text was updated successfully, but these errors were encountered: