Skip to content

gh-133467: fix data race in type_set_name - #137302

Merged
kumaraditya303 merged 4 commits into
python:mainfrom
kumaraditya303:type-races
Aug 1, 2025
Merged

gh-133467: fix data race in type_set_name#137302
kumaraditya303 merged 4 commits into
python:mainfrom
kumaraditya303:type-races

Conversation

@kumaraditya303

@kumaraditya303kumaraditya303 commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

This fixes two data races:

  • type_set_name: Assign the new name under stop the world pause to avoid data races with threads concurrently reading and writing name.
  • slot_tp_descr_get: Avoid assignment in slot_tp_descr_get as it is not thread safe in free-threading and is a minor optimization.

@kumaraditya303kumaraditya303 changed the title 133467: fix data race in type_set_namegh-133467: fix data race in type_set_nameAug 1, 2025

@colesburycolesbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@kumaraditya303
kumaraditya303 enabled auto-merge (squash) August 1, 2025 13:36
@kumaraditya303
kumaraditya303 merged commit e99bc7f into python:mainAug 1, 2025
44 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 1, 2025
Fix data race in `type_set_name` by assigning name under stop the world pause making it thread safe in free-threading.
(cherry picked from commit e99bc7f)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
@bedevere-app

Copy link
Copy Markdown

GH-137303 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.14 bugs and security fixes label Aug 1, 2025
@kumaraditya303
kumaraditya303 deleted the type-races branch August 1, 2025 13:41
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Fix data race in `type_set_name` by assigning name under stop the world pause making it thread safe in free-threading.
kumaraditya303 added a commit that referenced this pull request Oct 7, 2025
gh-133467: fix data race in `type_set_name` (GH-137302)
Fix data race in `type_set_name` by assigning name under stop the world pause making it thread safe in free-threading.
(cherry picked from commit e99bc7f)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@kumaraditya303@colesbury