Skip to content

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

Open
CharlieKerfoot wants to merge 5 commits into
python: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 into
python:mainfrom
CharlieKerfoot:fix-pickle-xid-cache-race

Conversation

@CharlieKerfoot

@CharlieKerfootCharlieKerfoot commented Apr 26, 2026

Copy link
Copy Markdown

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

python-cla-botBot commented Apr 26, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

Copy link
Copy Markdown

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

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.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label Jul 31, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviewstaleStale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@CharlieKerfoot