Store graph listener inside the context instead of the node graph (backport #2952)#2966
Store graph listener inside the context instead of the node graph (backport #2952)#2966mergify[bot] wants to merge 1 commit intojazzyfrom
Conversation
|
Cherry-pick of 715a983 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
ahcorde
left a comment
There was a problem hiding this comment.
@skyegalaxy do you mind to fix the conflicts ?
0759325 to
7106305
Compare
) * factor shutdown hook registration into its own method Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * run ament_uncrustify Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * consistent use of is_shutdown in graph-listener Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * this doesn't actually need to be a separate function Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * whitespace Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * fix typo Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * move graph listener into the context Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * make cpplint happy Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> * Update rclcpp/src/rclcpp/context.cpp Signed-off-by: Skyler Medeiros <smedeiros@irobot.com> --------- Signed-off-by: Skyler Medeiros <smedeiros@irobot.com>
7106305 to
4303518
Compare
|
Pulls: #2966 |
|
This is ABI breaking and may not be backported |
fujitatomoya
left a comment
There was a problem hiding this comment.
@jmachowinski thanks for letting me know that 👍
Description
This PR fixes a lock order inversion bug detected by Thread Sanitizer between
GraphListener::shutdown_mutex_andContext::on_shutdown_callbacks_mutex_, by storing and instantiating theGraphListenerinside of theContextinstead ofNodeGraph. With this change, we avoid locking the context weak pointer and inverting the order of lock acquisition on startup and shutdown.Usage of
is_shutdown_->load()was also replaced with the existingis_shutdown()method inGraphListenerfor consistency.Fixes # (2946)
Is this user-facing behavior change?
no
Did you use Generative AI?
no
Additional Information
This code appears to have remained unchanged for a long time, and I was able to reproduce this tsan error on iron, jazzy and rolling with this example. Tsan identified a lock order inversion as well as one potential data race in other parts of the code. With this change, the lock order inversion warning is gone, no additional tsan warnings were introduced, and all unit tests passed locally when these changes were built against both
jazzyandrolling.This is an automatic backport of pull request #2952 done by Mergify.