GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-149816: Fix another variant of race on setattr/managed dict going … by DinoV · Pull Request #160278 · python/cpython

Conversation

@DinoV

@DinoV DinoV commented Oct 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There's a couple of remaining issues with doing a setaddr. If we have a split dictionary we're not increfing the dictionary. Also, when we insert a split key it takes a lock which can cause the object/dict locks to be released so we need to guard against that.

The code here is pretty complex so it's also an attempt to simplify it. _PyObject_StoreInstanceAttribute loses any Py_GIL_DISABLEd ifdef's, instead we just have the main path with Py_BEGIN_CRITICAL_SECTION and FT_ATOMIC_LOAD_UINT8 and so on just turn into nothing when we're in the free threaded build.

I've also just updated things to go directly to _PyDict_SetItem_LockHeld when we're doing the dictionary version and made store_instance_attr_lock_held only be used when we don't have a materialized dictionary. Going through the fast split dictionary case it dictinsert isn't substantially different but it really complicates reasoning about what's going on here and causes `store_instance_attr_lock_held to need to handle a lot more cases.

  • Issue: 22 free-threading race conditions #149816

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot mentioned this pull request Oct 22, 2026
22 free-threading race conditions #149816
Open
13 of 24 tasks
@DinoV DinoV added the skip news label Oct 22, 2026
@DinoV
DinoV force-pushed the gh149816 branch 2 times, most recently from 2f8aa46 to 72a0e10 Compare October 22, 2026 23:17
@DinoV
pythongh-149816: Fix another variant of race on setattr/managed dict …
e1162cd
…going away
@DinoV
DinoV force-pushed the gh149816 branch from 72a0e10 to e1162cd Compare October 22, 2026 23:30
@DinoV

DinoV commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Perf results:
https://github.com/facebookexperimental/free-threading-benchmarking/tree/main/results/bm-20261022-3.16.0a1+dev-72a0e10-NOGIL
https://github.com/facebookexperimental/free-threading-benchmarking/tree/main/results/bm-20261022-3.16.0a1+dev-72a0e10

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

DinoV added 2 commits October 23, 2026 09:50
@DinoV
Fix comment
4a0f80a
@DinoV
Fix setdefault too
d1d63d7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane Awaiting requested review from methane methane will be requested when the pull request is marked ready for review methane is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon will be requested when the pull request is marked ready for review markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@DinoV
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.