rclpy icon indicating copy to clipboard operation
rclpy copied to clipboard

`rcl_shutdown` is not thread-safe when used in both `signal_handler` and `Context.__exit__`.

Open YuanYuYuan opened this issue 5 months ago • 4 comments

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 that rcutils_atomic_store on Thread 1 is set after the check rcl_context_is_valid on Thread 2. Therefore rcl_shutdown would be called twice and cause an error.

Analysis

Required Info:

  • Operating System:
    • Ubuntu 24.04
  • Installation type:
    • Docker
  • Version or commit hash:
    • ros-rolling
  • DDS implementation:
    • This bug is RMW independent. Any RMW implementation with a slow rmw_shutdown could lead to this issue.
  • Client library (if applicable):
    • Both rcl and rclpy are rolling.
  • Relevant issue: #1081

YuanYuYuan avatar Sep 02 '24 15:09 YuanYuYuan