Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Aug 1, 2025

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.

@kumaraditya303 kumaraditya303 changed the title 133467: fix data race in type_set_name gh-133467: fix data race in type_set_name Aug 1, 2025
Copy link
Contributor

@colesbury colesbury left a comment

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:main Aug 1, 2025
44 checks passed
@miss-islington-app
Copy link

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 <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Aug 1, 2025

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

@bedevere-app bedevere-app bot 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 <[email protected]>
Sign up for free to 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