Skip to content

Give each opaque buffer its own key - #2383

Merged
WyattBlue merged 2 commits into
mainfrom
patch
Aug 16, 2026
Merged

Give each opaque buffer its own key#2383
WyattBlue merged 2 commits into
mainfrom
patch

Conversation

@WyattBlue

Copy link
Copy Markdown
Member

OpaqueContainer keyed its entries on id(v), so one object attached to two frames produced a single entry shared by both buffers. Freeing either frame ran key_free, which popped that entry, and the other frame's opaque silently became None. Worse, once the object was released, a later object could land on the same address and be handed back through the stale key.

Hand out a fresh uint64 per add() instead. Every buffer then owns its entry, holders are independent, and the object is released once the last one goes away.

OpaqueContainer keyed its entries on id(v), so one object attached to
two frames produced a single entry shared by both buffers. Freeing
either frame ran key_free, which popped that entry, and the other
frame's opaque silently became None. Worse, once the object was
released, a later object could land on the same address and be handed
back through the stale key.

Hand out a fresh uint64 per add() instead. Every buffer then owns its
entry, holders are independent, and the object is released once the
last one goes away.
@WyattBlue
WyattBlue merged commit c0b4f35 into main Aug 16, 2026
8 checks passed
@WyattBlue
WyattBlue deleted the patch branch August 16, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant