Repository navigation
fix race on TrajectoryExecutionManager::execution_complete_ - #3853
Conversation
|
@rhaschke @christian-rauch @elyforl gentle ping on this fix for #3852; execution_complete_ is now std::atomic so stopExecution and the worker no longer race on a plain bool. happy to adjust if you'd rather keep the bool and take execution_state_mutex_ on every read instead. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds ChangesTrajectory execution synchronization
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The atomic completion flag addresses the reported race without changing the existing wait and stop behavior. No concrete user-facing regression is indicated, so merge risk is minimal. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
85c7c79 to
d273033
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3853 +/- ##
==========================================
- Coverage 48.91% 48.91% -0.00%
==========================================
Files 735 735
Lines 62684 62684
Branches 7617 7617
==========================================
- Hits 30658 30657 -1
- Misses 32026 32027 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
d273033 to
8590108
Compare
Fixes moveit#3852. Make execution_complete_ a std::atomic<bool> so concurrent unlocked reads in executeThread()/executePart() are synchronized with writes from stopExecution() (and the worker completion path) without changing the existing mutex + condition_variable join/wait protocol. Prefer atomic over forcing every hot-path poll under execution_state_mutex_, matching nearby planning code that uses std::atomic<bool> for cross-thread stop/preemption flags. Signed-off-by: Dundy Pasupuleti <dundysm@gmail.com>
Head branch was pushed to by a user without write access
8590108 to
4a9ba69
Compare
|
rebased onto current main (no conflicts; race fix unchanged, still just rolling-ci |
|
follow-up: after the rebase push, github actions for this fork pr are waiting on maintainer approval ( |
Description
Fixes #3852.
TrajectoryExecutionManager::execution_complete_was a plainboolused as a stop/completion flag betweenstopExecution()and the execution worker. Some accesses holdexecution_state_mutex_, whileexecuteThread()/executePart()(and a few other sites) read it without that mutex. That is a C++ data race: locking only the writer does not synchronize unlocked readers, and a laterjoin()does not repair earlier conflicting accesses.This change makes
execution_complete_astd::atomic<bool>. Existing assignment and boolean checks continue to work; the mutex +execution_complete_condition_protocol used bywaitForExecution()/ worker completion is unchanged, andstopExecution()still joins the worker the same way.Why atomic instead of mutex-only: #3198 already tightened locking around trajectory cleanup /
waitForRobotToStop(). Forcing every hot-path poll inexecutePart()underexecution_state_mutex_would change contention characteristics.std::atomic<bool>matches nearby planning code that uses atomics for cross-thread stop/preemption flags (for examplePlanExecution::preempt_).All call sites of
execution_complete_were audited; only the member type needed to change.Checklist
Test plan
execution_complete_access intrajectory_execution_manager.cpp/ header.moveit_ros_planning/ TrajectoryExecutionManager package build and gtests were not run here (no ROS/MoveIt desktop on the verification host). Existingtrajectory_execution_managergtests remain disabled/commented in that package'sCMakeLists.txt.boolreports a data race;std::atomic<bool>is clean. This is a pattern-level check, not a TSAN run of the MoveIt translation unit.Summary by CodeRabbit