Skip to content

Fix trajectory execution manager shutdown segfault - #3828

Open
MarqRazz wants to merge 6 commits into
moveit:mainfrom
MarqRazz:marq/fix/tem-shutdown
Open

MarqRazz wants to merge 6 commits into
moveit:mainfrom
MarqRazz:marq/fix/tem-shutdown

Conversation

@MarqRazz

@MarqRazz MarqRazz commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

TrajectoryExecutionManager segfaults on destruction whenever a controller manager plugin is loaded.

The controller manager creates action clients on the node it is given in initialize() and the rclcpp_action::Client is a Waitable, so the node's default callback group holds a weak reference to each. Becausecontroller_manager_loader_ is declared after controller_mgr_node_, the plugin and its loader are destroyed before the node causing it to crash on shutdown.

This PR destroys the objects in the correct order so that it can shutdown cleanly.

Summary by CodeRabbit

  • Bug Fixes
    • Improved shutdown and cleanup behavior for trajectory execution management.
    • Ensured controller-related resources are released in the correct order.
    • Reduced the risk of lingering resources or incomplete shutdowns when trajectory execution ends.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d1a884b and e7019e6.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The destructor now clears the parameter callback, removes the controller-manager node from the private executor, and resets the controller manager, node, and executor during shutdown.

Changes: Trajectory execution manager cleanup

Layer / File(s) Summary
Destructor resource release
moveit_ros/planning/trajectory_execution_manager/src/trajectory_execution_manager.cpp
The destructor clears the parameter callback, removes the controller-manager node from the private executor, and resets controller-manager and executor resources in shutdown order.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · previous review bf951

This change orders shutdown cleanup so controller-manager resources are released before their node, addressing the reported shutdown crash. No current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)

Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing a shutdown segmentation fault in the trajectory execution manager.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

🧪 Generate unit tests (beta)

  • Create PR with unit tests
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

ℹ️ Recent review info

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 29e82904-65f2-4331-977b-46c088589b1f

📥 Commits

Reviewing files that changed from the base of the PR and between 2f3fc0e and 911ec6a.

📒 Files selected for processing (1)

  • moveit_ros/planning/trajectory_execution_manager/src/trajectory_execution_manager.cpp
🚧 Files skipped from review as they are similar to previous changes (1)

  • moveit_ros/planning/trajectory_execution_manager/src/trajectory_execution_manager.cpp

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@MarqRazz MarqRazz added the backport PR requires backport to other distro branches listed in PR description label Aug 25, 2026
@codecov

codecov Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.73%. Comparing base (8c99e52) to head (d1a884b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3828      +/-   ##
==========================================
- Coverage   48.92%   48.73%   -0.18%     
==========================================
  Files         735      735              
  Lines       62699    62705       +6     
  Branches     7629     7631       +2     
==========================================
- Hits        30669    30554     -115     
- Misses      32030    32151     +121     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MarqRazz
MarqRazz requested a review from tylerjw September 4, 2026 14:27
@rhaschke

rhaschke commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why do unit tests fail again? Are they flaky? Triggered a new build...

@mergify

mergify Bot commented Nov 16, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

@130s
130s enabled auto-merge (squash) November 25, 2026 21:49
@130s

130s commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

CI has been a bit flaky but particular for this PR...I (or someone) have to look into it. From the first look, failures do look unrelated to the code change in this PR though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport PR requires backport to other distro branches listed in PR description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants