Skip to content

[3.15] gh-159185: Fix marshalling of a set modified while its elements are marshalled (GH-159195) - #159199

Merged
gpshead merged 1 commit into
python:3.15from
gpshead:backport-cd71799-3.15
Oct 11, 2026
Merged

gpshead merged 1 commit into
python:3.15from
gpshead:backport-cd71799-3.15

Conversation

@gpshead

@gpshead gpshead commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Marshalling a set element can run Python code (__buffer__, an audit hook) which changes the set. The number of elements was read before the loop, so a set which grew was written past the end of the list and one which shrank left NULL items in the list which was then sorted. Raise RuntimeError("set changed size during iteration") instead.

(cherry picked from commit cd71799)

[draft while determining if other backports should land first that would've let this be an automated backport]

…lements are marshalled (pythonGH-159195)

Marshalling a set element can run Python code (__buffer__, an audit
hook) which changes the set.  The number of elements was read before
the loop, so a set which grew was written past the end of the list and
one which shrank left NULL items in the list which was then sorted.
Raise RuntimeError("set changed size during iteration") instead.

(cherry picked from commit cd71799)
@gpshead gpshead self-assigned this Oct 11, 2026
@bedevere-app bedevere-app Bot added the type-crash A hard crash of the interpreter, possibly with a core dump label Oct 11, 2026
@gpshead
gpshead marked this pull request as ready for review October 11, 2026 21:51
@gpshead
gpshead enabled auto-merge (squash) October 11, 2026 21:51
@gpshead
gpshead merged commit 4c2433f into python:3.15 Oct 11, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-crash A hard crash of the interpreter, possibly with a core dump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant