Fix deadlock in buffer core - #979
Conversation
|
Thanks for opening the PR and my apologies for introducing the deadlock in #966 . I agree with the idea introduced here i.e., breaking the ABBA pattern by unlocking the mutex when running the cb. But restarting 'i' would mean complexity increases proportional to the number of pending requests. I think that can be avoided by first extracting all the pending callbacks, and then calling them. I have opened #982 which is based on your suggested idea while keeping the swap and pop behavior of the pending requests. Let me know if you agree with it. |
| callback_node.mapped()(request_handle, target_frame, source_frame, request_time, result); | ||
| lock.lock(); | ||
| // The callback or another thread may have changed the request vector. | ||
| i = 0; |
There was a problem hiding this comment.
If M callbacks fire per setTransform and N requests are pending, you get O(M·N) work instead of O(N) by going through the requests again each time.
There was a problem hiding this comment.
Good point, I am happy to close this and follow up on your PR instead
Description
This came up when I switch the default executor to EventsCBGExecutor in Nav2, tf2, and rclcpp. I have summarized my issue to my agent, and asks it to create some regression tests, one can verify that, without modifying anything in buffer core, the tests should end with a deadlock.
I also asked my agent to summarize the issue and changes:
I have verified that this pass all regression tests I added, and also works in Nav2 + tf2 + rclcpp when using EventsCBGExecutor by default.
Is this user-facing behavior change?
Yes, previously there is a deadlock, so this is a bugfix
Did you use Generative AI?
Yes, Codex Sol 5.6
Additional Information