Fix Godot crash at shutdown due to dangling signal callbacks#261
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
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>
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