Skip to content

Fix Godot crash at shutdown due to dangling signal callbacks#261

Merged
niyazmft merged 3 commits into
mainfrom
fix-shutdown-crash-dangling-signals-9964384375986748755
Jun 8, 2026
Merged

Fix Godot crash at shutdown due to dangling signal callbacks#261
niyazmft merged 3 commits into
mainfrom
fix-shutdown-crash-dangling-signals-9964384375986748755

Conversation

@niyazmft

@niyazmft niyazmft commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Fixed a critical shutdown crash in Godot caused by dangling signal callbacks. Added _exit_tree() methods to disconnect signals from Autoloads and global nodes in 22 identified scripts across the codebase. Verified the fix by ensuring clean exit (code 0) in headless mode.

Fixes #244


PR created automatically by Jules for task 9964384375986748755 started by @niyazmft

Godot was crashing with EXC_BAD_ACCESS during headless shutdown because
several scripts connected to Autoload singleton signals or global node
signals (like Viewport or SceneTree root) but never disconnected them.
This led to use-after-free errors when the engine attempted to call back
into partially or fully destroyed script instances during singleton
teardown.

Changes:
- Added `_exit_tree()` overrides to 22 scripts to explicitly disconnect
  from Autoloads (EventBus, EntityLifecycle, BurdenManager, etc.) and
  globals (SafeZoneManager, InputRouter, Viewport).
- Implemented `is_connected()` checks in `_exit_tree()` to ensure robust
  disconnection logic.
- Converted anonymous lambda connections to named methods in
  `VersionLabel` to facilitate reliable disconnection.
- Verified clean shutdown with exit code 0 via `godot --headless --quit`.

This fix unblocks CI pipelines and headless test suite execution.

Co-authored-by: niyazmft <9331133+niyazmft@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits June 8, 2026 20:12
Godot was crashing with EXC_BAD_ACCESS during headless shutdown because
several scripts connected to Autoload singleton signals or global node
signals (like Viewport or SceneTree root) but never disconnected them.
This led to use-after-free errors when the engine attempted to call back
into partially or fully destroyed script instances during singleton
teardown.

Changes:
- Added `_exit_tree()` overrides to 22 scripts to explicitly disconnect
  from Autoloads (EventBus, EntityLifecycle, BurdenManager, etc.) and
  globals (SafeZoneManager, InputRouter, Viewport).
- Implemented `is_connected()` checks in `_exit_tree()` to ensure robust
  disconnection logic.
- Converted anonymous lambda connections to named methods in
  `VersionLabel` to facilitate reliable disconnection.
- Fixed GDScript formatting issues in `scripts/ui/remap_panel.gd` and
  `scripts/autoload/burden_shader_manager.gd` to satisfy CI checks.
- Verified clean shutdown with exit code 0 via `godot --headless --quit`.

This fix unblocks CI pipelines and headless test suite execution.

Co-authored-by: niyazmft <9331133+niyazmft@users.noreply.github.com>
@niyazmft niyazmft merged commit 5e97e23 into main Jun 8, 2026
4 checks passed
@niyazmft niyazmft deleted the fix-shutdown-crash-dangling-signals-9964384375986748755 branch June 8, 2026 20:16
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.

bug(Godot): crash at shutdown due to dangling signal callback (TurnManager)

1 participant