← Back to Pull requests

[MPPI] Fix segfault when a critic fails to configure in a composed bring-up #6779

Closed
unknown closed this pull request without merging on Nov 17, 2026 23:31 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 08:51 UTC
Author

<!-- Please fill out the following pull request template for non-trivial changes to help us process your PR faster and more efficiently.-->

---

Basic Info

| Info | Please fill out this column |
| ------ | ----------- |
| Ticket(s) this addresses | #6637 (the Jazzy segfault; see below for Rolling) |
| Primary OS tested on | Ubuntu (ros:jazzy-ros-base and ros:rolling-ros-base Docker images) |
| Robotic platform tested on | none: the composed controller_server bring-up from #6637, without a robot |
| Does this PR contain AI generated software? | Yes. It was written with Claude Code and checked by reproducing #6637 on Jazzy before and after each change (with gdb backtraces), building and running the nav2_mppi_controller unit tests on main, plus ament_uncrustify and ament_cpplint |
| Was this PR description generated by AI software? | Yes, written with Claude Code for me; I have checked the PR and the description myself |

---

Description of contribution in a few bullet points

When MPPIController::configure() throws (#6637: CostCritic with consider_footprint: true on a radius-based costmap), controller_server destroys the controller without cleanup(). In a composed bring-up on Jazzy this crashes the container in two places, one after the other. Each commit fixes one:

Release parameter callbacks before unloading the plugins. MPPIController declares parameters_handler_ before optimizer_, so optimizer_ (with the critic manager, the trajectory validator and their pluginlib loaders) is destroyed first, and class_loader can unload libmppi_critics.so. ~ParametersHandler then destroys the std::function callbacks the critics registered through getParamGetter()/setParamCallback(). Those were instantiated in the critics library. Backtrace with the Jazzy debs:

  #0  0x00007b5910183390 in ?? ()
  #1  mppi::ParametersHandler::~ParametersHandler() () from /opt/ros/jazzy/lib/libmppi_controller.so
  #2  ?? () from /opt/ros/jazzy/lib/libmppi_controller.so
  #3  class_loader::ClassLoader::onPluginDeletion<nav2_core::Controller>(nav2_core::Controller*) () from /opt/ros/jazzy/lib/libcontroller_server_core.so
  

Fix: a destructor that calls cleanup(), which releases parameters_handler_ before the members are destroyed. The class layout stays the same, so this should be backportable.
Rethrow critic configuration errors from mppi_controller. With only the first fix, the container still crashes: the ControllerException was created by code in the critics library, and that library is unloaded while the exception propagates. The lifecycle node's handler then calls what() through a vtable in unmapped memory (call 0x10(%rax) in LifecycleNodeInterfaceImpl::change_state), so the error message is never printed. Fix: CriticManager::loadCritics() catches the exception from on_configure() and rethrows a nav2_core::ControllerException with the same message, created in mppi_controller, which stays loaded.
With both changes the composed bring-up fails cleanly, as in the stand-alone case from #6637:
  [ERROR] [controller_server]: Original error: Considering footprint in collision checking but no robot footprint provided in the costmap.
  [WARN] [controller_server]: Callback returned ERROR during the transition: configure
  

Affected branches:

| Branch | Affected | Patch applies | How checked |
|---|---|---|---|
| main | same code, but I could not reproduce the crash | this PR | My source builds of the plugin libraries contain STB_GNU_UNIQUE symbols, so glibc never unmaps them and nothing crashes. The Jazzy debs have none (readelf --dyn-syms libmppi_critics.so), which is why Jazzy crashes. |
| lyrical | same code | yes, clean | by inspection |
| kilted | same code | yes, clean | by inspection |
| jazzy | yes | yes, clean | reproduced, both fixes verified (table below) |
| humble | same code | yes, clean | by inspection |

Could a maintainer add the backport-jazzy label (and backport-kilted, backport-lyrical and backport-humble if you want them there too)? Maybe this answers the question in #6637 about a fix for Jazzy. I did not use "Fixes #6637" because merging into main alone does not fix Jazzy.

Description of documentation updates required from your changes

None.

Description of how this change was tested

#6637 reproduced on Jazzy (ros:jazzy-ros-base): component_container_isolated, load nav2_controller::ControllerServer with -p 'controller_plugins:=["FollowPath"]' -p FollowPath.plugin:=nav2_mppi_controller::MPPIController -p 'FollowPath.critics:=["ConstraintCritic","GoalCritic","CostCritic"]' -p FollowPath.CostCritic.consider_footprint:=true (default costmap, so radius only), then ros2 lifecycle set /controller_server configure. Three runs per case:

| nav2_mppi_controller | Result |
|---|---|
| 1.3.13 from the Jazzy debs | container segfaults (139) in ~ParametersHandler, 3/3 runs, no error message |
| jazzy branch + first commit only | container segfaults (139) in the what() call, 3/3 |
| jazzy branch + second commit only | container segfaults (139), 3/3 |
| jazzy branch + both commits | configure fails cleanly ("Transitioning failed"), error message printed, container keeps running, 3/3 |

The source builds used -DCMAKE_CXX_FLAGS=-fno-gnu-unique so that, like the debs, the libraries have no STB_GNU_UNIQUE symbols and can really be unloaded.
main in ros:rolling-ros-base: nav2_mppi_controller builds, and controller_state_transition_test, critic_manager_test, critics_tests, optimizer_smoke_test, optimizer_unit_tests, parameter_handler_test and motion_model_tests pass.
ament_uncrustify and ament_cpplint report no problems for the changed files.
I did not add a unit test. A test that destroys a controller after a failed configure() passes even without the fix, because the test binary links libmppi_controller directly and the critics' std::function handlers then resolve to its copies. The bug only shows when the controller itself is loaded as a plugin.

---

Future work that may be required in bullet points

The trajectory validator and (on main) the motion model plugins can throw from their initialize() in the same way. I only changed the critics path, which is the one reported.

For Maintainers: <!-- DO NOT EDIT OR REMOVE -->


  • Check that any new parameters added are updated in docs.nav2.org

  • Check that any significant change is added to the migration guide

  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide

  • Check that any new functions have Doxygen added

  • Check that any new features have test coverage

  • Check that any new plugins is added to the plugins page

  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

  • Should this be backported to current distributions? If so, tag with backport-.
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: MatthijsBurgh Review duration: 8080m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.80) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.80 · 650 lines diff across 8 files
    0.80
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.080
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #6779"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 80.2% (HIGH) · Higher = larger blast radius
    80.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 31.7% · Safe to merge
    31.7%