Skip to content

Clean shutdown fix (deployable = qiayuanl devel + fix) - #1

Merged
T-K-233 merged 9 commits into
mainfrom
fix/clean-shutdown-sigsegv
Jul 20, 2026
Merged

Clean shutdown fix (deployable = qiayuanl devel + fix)#1
T-K-233 merged 9 commits into
mainfrom
fix/clean-shutdown-sigsegv

Conversation

@T-K-233

@T-K-233 T-K-233 commented Jul 20, 2026

Copy link
Copy Markdown
Member

Makes this fork's main the version we actually deploy: qiayuanl's devel branch 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), so main started as rxdu's upstream, which has diverged from the qiayuanl devel branch 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-forwards main to our deployed tree (the fix commit 7f4c2ea is 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

rxdu and others added 9 commits March 13, 2025 21:11
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
@T-K-233
T-K-233 merged commit dcb3ab0 into main Jul 20, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants