Skip to content

Fix race condition in ActionBasedTreeExecutorNode: per-goal TreeConstructor storage via UUID map#19

Merged
robin-mueller merged 2 commits intofeature/event-based-executorfrom
copilot/sub-pr-18
Mar 6, 2026
Merged

Fix race condition in ActionBasedTreeExecutorNode: per-goal TreeConstructor storage via UUID map#19
robin-mueller merged 2 commits intofeature/event-based-executorfrom
copilot/sub-pr-18

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

pending_tree_constructor_ was a single shared member written in handle_trigger_goal_() and consumed in handle_trigger_accept_(). Two goals accepted before startExecution() marked the executor busy would overwrite each other's constructor, causing the wrong tree to execute.

Changes

  • pending_tree_constructor_pending_tree_constructors_: replaced the single TreeConstructor with std::map<rclcpp_action::GoalUUID, TreeConstructor>, keyed by goal UUID.
  • handle_trigger_goal_(): stores the constructor into the map under the incoming UUID instead of overwriting a shared member.
  • handle_trigger_accept_(): retrieves and removes the constructor atomically via map::extract(), eliminating any window where a stale or overwritten entry could be consumed.
// Before — shared member, last writer wins
pending_tree_constructor_ = getTreeConstructorFromGoal(goal_ptr);   // handle_trigger_goal_
startExecution(pending_tree_constructor_, ...);                      // handle_trigger_accept_

// After — per-goal, keyed by UUID
pending_tree_constructors_[uuid] = getTreeConstructorFromGoal(goal_ptr);  // handle_trigger_goal_
auto node = pending_tree_constructors_.extract(uuid);                     // handle_trigger_accept_
startExecution(std::move(node.mapped()), ...);

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…dition

Co-authored-by: robin-mueller <83639955+robin-mueller@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on Tree executor modularity PR Fix race condition in ActionBasedTreeExecutorNode: per-goal TreeConstructor storage via UUID map Mar 6, 2026
@robin-mueller robin-mueller marked this pull request as ready for review March 6, 2026 13:29
@robin-mueller robin-mueller merged commit abeaa79 into feature/event-based-executor Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants