-
Notifications
You must be signed in to change notification settings - Fork 227
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
rcl_shutdown
is not thread-safe when used in both signal_handler
and Context.__exit__
.
#1352
Comments
After checking code, there is a issue. Thread 1 rclpy/rclpy/src/rclpy/context.cpp Lines 42 to 53 in 464a357
Thread 2 Before calling rcl_shutdown(), rclpy/rclpy/src/rclpy/context.cpp Lines 150 to 165 in 464a357
If thread 2 executes rcl_shutdown first, thread 1 can still call rcl_shutdown again. I create a fix #1353. |
Hi @Barry-Xu-2018! Thanks for your attempt. But it seemed not to work... |
My fixing only prevented simultaneous calls to rcl_shutdown(). I have updated fixing. Please try again. Currently, rclpy is designed to throw an exception if rcl_shutdown() is called multiple times on the same context (there's a specific test case for this). So, the error is expected behavior. However, in your situation, it shouldn't throw an error, but rather ignore the second shutdown call. |
Hi @Barry-Xu-2018, I have confirmed your latest fix resolves the issue (no more duplicated |
Bug report
We found this sporadic failure with rclpy (rolling) due to the race condition while calling
rcl_shutdown
.In this issue, the conflict happens if
rmw_shutdown
is slow so thatrcutils_atomic_store
on Thread 1 is set after the checkrcl_context_is_valid
on Thread 2. Thereforercl_shutdown
would be called twice and cause an error.Analysis
Thread 1
Thread 2
Required Info:
rmw_shutdown
could lead to this issue.The text was updated successfully, but these errors were encountered: