Skip to content

[mypyc] Fix free-threading race condition in argument parsing#21613

Merged
JukkaL merged 2 commits into
masterfrom
mypy-parallel-crash
Jun 15, 2026
Merged

[mypyc] Fix free-threading race condition in argument parsing#21613
JukkaL merged 2 commits into
masterfrom
mypy-parallel-crash

Conversation

@JukkaL

@JukkaL JukkaL commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Global argument parser state initialization was missing synchronization.

Don't use a mutex on the hot path as an optimization.

Fixes #21578 (probably). I added a regression test that failed about 30% of time on master (on macOS).

I used coding agent assist.

JukkaL added 2 commits June 15, 2026 12:28
Global argument parser state initialization was missing synchronization.

Don't use a mutex on the hot path as an optimization.

Fixes #21578.
@JukkaL JukkaL requested review from ilevkivskyi and msullivan June 15, 2026 13:14

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Hopefully this should fix the parallel parsing race.

@JukkaL JukkaL merged commit 8b6642d into master Jun 15, 2026
18 checks passed
@JukkaL JukkaL deleted the mypy-parallel-crash branch June 15, 2026 13:47
@JukkaL JukkaL mentioned this pull request Jun 15, 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.

Parallel parsing sometimes crashes when compiled in free-threaded Python

2 participants