10000 gh-129701: Fix a data race in `intern_common` in the free threaded build by colesbury · Pull Request #130089 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-129701: Fix a data race in intern_common in the free threaded build #130089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2025

Conversation

colesbury
Copy link
Contributor
@colesbury colesbury commented Feb 13, 2025
  • Use a mutex to avoid potentially returning a non-immortalized string, because immortalization happens after the insertion into the interned dict.

  • Use Py_DECREF() calls instead of Py_SET_REFCNT(s, Py_REFCNT(s) - 2) for thread-safety. This code path isn't performance sensitive, so just use Py_DECREF() unconditionally for simplicity.

…ded build

* Use a mutex to avoid potentially returning a non-immortalized string,
  because immortalization happens after the insertion into the interned
  dict.

* Use `Py_DECREF()` calls instead of `Py_SET_REFCNT(s, Py_REFCNT(s) - 2)`
  for thread-safety. This code path isn't performance sensistive, so
  just use `Py_DECREF()` unconditionally for simplicity.
@colesbury colesbury added skip news 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section topic-free-threading labels Feb 13, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @colesbury for commit a12edba 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F30617%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

@colesbury colesbury marked this pull request as ready for review February 14, 2025 00:37
@colesbury colesbury requested review from encukou and mpage February 14, 2025 00:37
Copy link
Contributor
@mpage mpage left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member
@encukou encukou left a comment

Choose a reason for hiding this comment

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

LGTM! I didn't check if this solves the issue, but it looks like an improvement.

@encukou encukou merged commit b9d2ee6 into python:main Feb 17, 2025
47 checks passed
@colesbury colesbury deleted the gh-129701-intern-common branch February 18, 2025 16:00
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.

4 participants
0