[Bugfix] UIEntity has no tp_dealloc — Py_INCREF(self) in init() is never balanced #275
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#275
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?
Summary
UIEntity::init()callsPy_INCREF(self)at line 249 to store a back-reference, butPyUIEntityTypehas notp_deallocdefined — it defaults to the base type's dealloc which does not callPy_DECREFondata->self. This means every Entity object has an extra unbalanced reference that is never released.This is closely related to #266 (the reference cycle issue), but is a distinct problem: even if the
selffield is removed, the missingtp_deallocmeans there's no custom cleanup for entities at all.Root Cause
UIEntity.h:132-172— PyUIEntityType definition:UIEntity.cpp:248-249— init creates the reference:Without a
tp_dealloc, there's no place to:Py_DECREFondata->selfPyObject_ClearWeakRefs)shared_ptr<UIEntity>properlyImpact
weakreflistmember is never cleaned upshared_ptr<UIEntity>data member is never explicitly releasedFix
Add a proper
tp_dealloc:And set it in the type:
Severity
High — combined with #266, this ensures every entity leaks permanently. The missing dealloc also means weak references and shared_ptrs are not properly cleaned up.
Related
Py_INCREFthat creates the leak)