Skip to content

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

@niyazmft

Description

@niyazmft

Summary

Godot crashes with EXC_BAD_ACCESS (SIGABRT) during headless shutdown (Main::cleanup). The crash stack shows GDScriptInstance::~GDScriptInstance()Object::_predelete()Variant::_clear_internal() with a dangling recursive_mutex at 0x1d8. This is a use-after-free on a GDScriptInstance during singleton teardown.

Root Cause

scripts/combat/turn_manager.gd:29-32 connects to EntityLifecycle.entity_state_changed in _ready() but never disconnects in _exit_tree(). Since EntityLifecycle is an autoload singleton, when Godot cleans up at shutdown, the order of singleton destruction can leave TurnManagers signal callback pointing to freed memory.

Impact

  • CI pipeline always crashes (blocking all workflows)
  • Headless test suite cannot complete
  • Any gameplay session that exits back to menu will also crash

Location

scripts/combat/turn_manager.gd — missing _exit_tree() override

Suggested Fix

Add an _exit_tree() method in turn_manager.gd that disconnects EntityLifecycle.entity_state_changed if connected. Audit all other autoload signal connections in the project for the same pattern.

Priority: P0 · Size: S · Status: Ready

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjulesGating label for Google Jules offload

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions