Clean shutdown fix (deployable = qiayuanl devel + fix) - #1
Merged
Conversation
The SIGINT handler deleted the mjModel/mjData and tore down the plugins + rclcpp from inside the signal handler while PhysicsThread was mid-mj_step -- a use-after-free that SIGSEGV'd on exit (and all of it is non-async-signal-safe). - handler now only sets sim.exitrequest (async-signal-safe); RenderLoop + PhysicsLoop already poll it - disable rclcpp's own signal handling (InitOptions::shutdown_on_signal= false) so ours is the sole SIGINT handler - free the mjModel/mjData in main() after both worker threads join (the plugins/controller_manager still reference them), not in PhysicsThread - after the functional teardown (rclcpp::shutdown + drop plugins -> controllers deactivated, hardware shut down), _exit(0) to skip the fragile cross-library static / plugin-library unload destruction that otherwise corrupts the heap on exit Result: mujoco_sim exits cleanly (code 0) on Ctrl-C / ros2 launch SIGINT. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QKJQ9hze1hMWXJpdPcjp3
This fork deploys qiayuanl's devel branch of mujoco_sim_ros2 (used by our deployment stack) plus our clean-shutdown-on-Ctrl-C fix -- NOT rxdu upstream, which has diverged. This -s ours merge keeps our deployed tree exactly and records rxdu/main as an ancestor so 'main' can fast-forward to it without pulling in rxdu's divergent changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012QKJQ9hze1hMWXJpdPcjp3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes this fork's
mainthe version we actually deploy: qiayuanl'sdevelbranch of mujoco_sim_ros2 + our clean-shutdown-on-Ctrl-C fix.Context: this repo is a fork of
rxdu/mujoco_sim_ros2(the grand source), somainstarted as rxdu's upstream, which has diverged from the qiayuanldevelbranch our stack runs. Rather than a nonsensical 3-way merge of two incompatible lineages, the head branch-s ours-merges rxdu/main as a superseded ancestor, so this PR fast-forwardsmainto our deployed tree (the fix commit7f4c2eais preserved and reachable). rxdu's changes are recorded in history but not applied.Mirrors Berkeley-Humanoids/mujoco_ros2_control#1.
🤖 Generated with Claude Code
https://claude.ai/code/session_012QKJQ9hze1hMWXJpdPcjp3