[Bugfix] UIGridPoint::parent_grid is a dangling raw pointer #271
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.
Depends on
#252
GridView and Grid, FOVLayer and PathLayer
john/McRogueFace
Reference
john/McRogueFace#271
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
UIGridPointstores its parent grid as a rawUIGrid*pointer (UIGridPoint.h:44). This pointer is used for TCOD map synchronization whenwalkableortransparentproperties are set. While thePyUIGridPointObjectstruct holds ashared_ptr<UIGrid>to keep the grid alive, theUIGridPointitself stores a raw pointer that isn't covered by the same safety.Root Cause
UIGridPoint.h:44:Used in
UIGridPoint.cpp:86-87:The
PyUIGridPointObjectwrapper (UIGridPoint.h:23-27) stores:The
shared_ptr<UIGrid> gridon the Python wrapper keeps the grid alive while the GridPoint object exists, which prevents the immediate dangling issue. However, theUIGridPointstruct itself doesn't know about the shared_ptr, andparent_gridis set during grid construction (UIGrid.cpp:115, 128) as a raw pointer.Risk Assessment
Currently mitigated by the
shared_ptr<UIGrid>onPyUIGridPointObject. The grid can't be destroyed while a Python GridPoint object references it.Fragile because:
Fix
Consider making
UIGridPoint::parent_gridastd::weak_ptr<UIGrid>or documenting the invariant thatPyUIGridPointObject::gridmust always be set correctly.Severity
Low — currently protected by the Python wrapper's shared_ptr, but the pattern is fragile and error-prone for future development.
GridViewandGrid,FOVLayerandPathLayerDeferred from the #258–#278 memory safety audit. In #252, UIGridPoint becomes a lightweight proxy that reads/writes named DiscreteMap slots on GridMap — the
parent_gridraw pointer is eliminated entirely. The Phase 4 work (commit115e16f) already converted PyUIGridPointObject from rawUIGridPoint*to coordinate-based(grid, x, y)access, which mitigates the Python-facing risk. The remaining C++UIGridPoint::parent_gridfield disappears with the #252 rearchitecture. Linked as dependency of #252.GridViewandGrid,FOVLayerandPathLayer#252Roadmap context
Folded into #252 (Grid/GridView split) in the Grid & Entity Overhaul Roadmap (
docs/GRID_ENTITY_OVERHAUL_ROADMAP.md), Phase 4. RawUIGrid*in UIGridPoint will becomeweak_ptr<Grid>during the architecture overhaul.GridViewandGrid,FOVLayerandPathLayer#252