Skip to content

gh-157841: Synchronize functools.partial state access - #160480

Draft
mpage wants to merge 1 commit into
python:mainfrom
mpage:gh-157979-ft-functools-partial
Draft

mpage wants to merge 1 commit into
python:mainfrom
mpage:gh-157979-ft-functools-partial

Conversation

@mpage

@mpage mpage commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Acquire coherent strong-reference snapshots under the partial object lock for calls, repr, reduce, and nested-partial construction. Publish replacement state atomically, release displaced references after publication, and retire replaced instance dictionaries through QSBR. Keep free-threaded vectorcall dispatch immutable after construction.

Add concurrent state/coherence coverage, placeholder-aware flattening tests, and regressions for reentrant keyword merging and finalizers.

Authored with AI and reviewed by me.

Acquire coherent strong-reference snapshots under the partial object lock for
calls, repr, reduce, and nested-partial construction. Publish replacement state
atomically, release displaced references after publication, and retire replaced
instance dictionaries through QSBR. Keep free-threaded vectorcall dispatch
immutable after construction.

Add concurrent state/coherence coverage, placeholder-aware flattening tests, and
regressions for reentrant keyword merging and finalizers.

@espressolee espressolee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran the reproducer from the issue against this PR (cae9916) and its parent (738d055). macOS arm64, --disable-gil builds, 4 s per run.

Release builds, PYTHONMALLOC=debug, 10 runs per mode:

mode   738d055        cae9916
ro     10/10 ok       10/10 ok
rw     0/10 (segv)    10/10 ok
ww     0/10 (segv)    10/10 ok
cw     0/10 (segv)    10/10 ok

TSan builds (--with-thread-sanitizer, in-tree FT suppressions file which has no active entries, halt_on_error=0), 3 runs per mode:

mode   738d055               cae9916
ro     no reports            no reports
rw     reports in 3/3 runs   no reports
ww     reports in 3/3 runs   no reports
cw     reports in 3/3 runs   no reports

The parent had 6-21 data race warnings per rw/ww/cw run, with top frames in partial_setstate and partial_setvectorcall; those runs ended in SIGABRT, SIGKILL or a 300 s timeout. All 12 PR TSan runs exited 0 with no warnings. No crashes or TSan reports with the PR in these runs.

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