[MPPI] Fix segfault when a critic fails to configure in a composed bring-up #6779
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
MatthijsBurgh
<!-- 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-baseandros:rolling-ros-baseDocker images) || Robotic platform tested on | none: the composed
controller_serverbring-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_controllerunit tests onmain, plusament_uncrustifyandament_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:CostCriticwithconsider_footprint: trueon a radius-based costmap),controller_serverdestroys the controller withoutcleanup(). 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.
MPPIControllerdeclaresparameters_handler_beforeoptimizer_, sooptimizer_(with the critic manager, the trajectory validator and their pluginlib loaders) is destroyed first, and class_loader can unloadlibmppi_critics.so.~ParametersHandlerthen destroys thestd::functioncallbacks the critics registered throughgetParamGetter()/setParamCallback(). Those were instantiated in the critics library. Backtrace with the Jazzy debs:Fix: a destructor that calls
cleanup(), which releasesparameters_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
ControllerExceptionwas created by code in the critics library, and that library is unloaded while the exception propagates. The lifecycle node's handler then callswhat()through a vtable in unmapped memory (call 0x10(%rax)inLifecycleNodeInterfaceImpl::change_state), so the error message is never printed. Fix:CriticManager::loadCritics()catches the exception fromon_configure()and rethrows anav2_core::ControllerExceptionwith the same message, created inmppi_controller, which stays loaded.With both changes the composed bring-up fails cleanly, as in the stand-alone case from #6637:
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_UNIQUEsymbols, 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-jazzylabel (andbackport-kilted,backport-lyricalandbackport-humbleif 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 intomainalone 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, loadnav2_controller::ControllerServerwith-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), thenros2 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 ||
jazzybranch + first commit only | container segfaults (139) in thewhat()call, 3/3 ||
jazzybranch + second commit only | container segfaults (139), 3/3 ||
jazzybranch + both commits | configure fails cleanly ("Transitioning failed"), error message printed, container keeps running, 3/3 |The source builds used
-DCMAKE_CXX_FLAGS=-fno-gnu-uniqueso that, like the debs, the libraries have noSTB_GNU_UNIQUEsymbols and can really be unloaded.maininros:rolling-ros-base:nav2_mppi_controllerbuilds, andcontroller_state_transition_test,critic_manager_test,critics_tests,optimizer_smoke_test,optimizer_unit_tests,parameter_handler_testandmotion_model_testspass.ament_uncrustifyandament_cpplintreport 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 linkslibmppi_controllerdirectly and the critics'std::functionhandlers 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 theirinitialize()in the same way. I only changed the critics path, which is the one reported.For Maintainers: <!-- DO NOT EDIT OR REMOVE -->
backport-.🤖 Generated with Claude Code