Skip to content

[mypyc] Make tagged int attributes memory safe under free threading - #22203

Merged
JukkaL merged 3 commits into
masterfrom
mypyc-safe-attr-int
Oct 16, 2026
Merged

JukkaL merged 3 commits into
masterfrom
mypyc-safe-attr-int

Conversation

@JukkaL

@JukkaL JukkaL commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Previously native tagged int attributes used completely unsynchronized
access, which could result in use after free or double frees. Fix the
memory safety issues, but only synchronize if an int has a long value
(tag bit set and not undefined).

It can still leak memory if there is a race condition involving long
integers (e.g. 2**62 or larger on a 64-bit platform). This is a compromise
to avoid slowing down very common (and fast) operations with short
tagged integers.

The implementation is otherwise similar to attributes with regular
reference types.

This doesn't have a measurable impact on self check performance
on Python 3.14t.

Work on mypyc/mypyc#1203.

…ding

It can still leak memory if there is a race condition involving big
integers (e.g. 2**62 or larger on a 64-bit platform). This is a compromise
to avoid slowing down very common (and fast) operations.

Work on mypyc/mypyc#1203.
@JukkaL JukkaL changed the title [mypyc] Make tagged int attribute access memory safe under free threading [mypyc] Make tagged int attributes memory safe under free threading Oct 14, 2026
@JukkaL
JukkaL requested a review from msullivan October 14, 2026 13:20
@JukkaL
JukkaL merged commit c39fc6d into master Oct 16, 2026
18 checks passed
@JukkaL
JukkaL deleted the mypyc-safe-attr-int branch October 16, 2026 15:04
@ilevkivskyi

Copy link
Copy Markdown
Member

This broke master again. I know move fast and break things is cool, but it is actually not.

@JukkaL

JukkaL commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

This conflicted with #22073, I think. I'm working on a forward fix.

@JukkaL

JukkaL commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

I guess we should merge master and let CI run before merging a PR when there is a lot of commit activity and the PR has been open for a few days.

JukkaL added a commit that referenced this pull request Oct 16, 2026
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.

3 participants