segfault: use of animations causes segfault on exit #175
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#175
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
More of an annoyance than anything, as the program is already shutting down. Regardless, there is technically a lifecycle issue: the Python interpreter is made unavailable while some C++ objects still hold references to Python objects which they attempt to refmanage.
Summary of the Bug Fix
Root Cause: When sys.exit() was called, Python's interpreter began shutting down. The AnimationManager singleton was destroyed during the atexit handler phase, but at that point Python was already finalized. When Animation::~Animation() tried to call PyGILState_Ensure() to safely decrement Python callback references, it crashed because the interpreter state was already invalid.
Fix: Added Py_IsInitialized() guards before any Python API calls in Animation::~Animation():
This pattern should be applied to any C++ destructor that handles Python objects when the object might outlive the Python interpreter (e.g., singletons, static objects, or objects destroyed during exit handlers).
segfault: use of animations causesto segfault: use of animations causes segfault on exit