ros2
runtime_error
ai_generated
true
Deadlock detected: callback waiting for another callback in same MutuallyExclusiveCallbackGroup
ID: ros2/rclcpp-callback-group-deadlock
82%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
Calling a service synchronously inside a callback deadlocks the executor. The service response callback cannot run.
genericWorkarounds
-
92% success Use async service calls (call_async) inside callbacks
future = client.call_async(request); rclpy.spin_until_future_complete(self, future)
-
90% success Use MultiThreadedExecutor with ReentrantCallbackGroup for the service client
cb_group = ReentrantCallbackGroup(); client = self.create_client(srv_type, name, callback_group=cb_group)
-
82% success Move the service call to a separate thread
import threading; threading.Thread(target=sync_service_call).start()
Dead Ends
Common approaches that don't work:
-
Use a longer timeout on the synchronous service call
92% fail
The call can never complete because the executor is blocked; timeout just delays the deadlock detection
-
Create a new single-threaded executor per service call
85% fail
Multiple executors on the same node cause undefined behavior with callbacks