[Bugfix] UniformCollection stores raw pointer without checking weak_ptr owner before access #272
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#272
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
PyUniformCollectionObjectstores a rawUniformCollection*pointer to memory owned by aUIDrawable, and astd::weak_ptr<UIDrawable> ownerfor validity checking. However, the accessor methods only checkif (!self->collection)(NULL check on the raw pointer) — they never checkself->owner.lock(). If the owning UIDrawable is destroyed,collectionbecomes a dangling pointer that passes the NULL check.Root Cause
PyUniformCollection.h:84-89:All accessor methods check the raw pointer but not the weak_ptr:
PyUniformCollection.cpp:176(mp_subscript):Same pattern in:
mp_length(line 169)mp_ass_subscript(line 242)repr(line 154)The
ownerweak_ptr exists precisely for validity checking but is never used in any accessor method.Reproduction
Fix
Check
owner.lock()before accessing the raw pointer in all methods:Severity
Medium — use-after-free when UIDrawable is destroyed while a Python reference to its uniforms persists. Requires specific code pattern to trigger but leads to undefined behavior.