Skip to content

gh-149000: Fix race / leak in pickle XID per-interpreter cae#149002

Open
CharlieKerfoot wants to merge 5 commits intopython:mainfrom
CharlieKerfoot:fix-pickle-xid-cache-race
Open

gh-149000: Fix race / leak in pickle XID per-interpreter cae#149002
CharlieKerfoot wants to merge 5 commits intopython:mainfrom
CharlieKerfoot:fix-pickle-xid-cache-race

Conversation

@CharlieKerfoot
Copy link
Copy Markdown

@CharlieKerfoot CharlieKerfoot commented Apr 26, 2026

To fix issue #149000, I replace the load/store with an atomic compare-exchange. The fast path is a relaxed atomic load.
Population imports the attribute, then attempts to CAS it into the slot. On a lost CAS, the loser
Py_DECREFs its own reference and returns the winner's pointer (now owned by the slot).

Used a helper _cache_pickle_attr() because the logic was the same for the dumps and loads getters.

Tests

Existing test_interpreters / InterpreterPoolExecutor tests still pass under the GIL build
Same under --disable-gil

Fixed issue: #149000

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 26, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 26, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 26, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

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.

1 participant