]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-105699: Fix an Interned Strings Crasher (gh-106930) (#106963)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 21 Jul 2023 20:28:22 +0000 (13:28 -0700)
committerGitHub <noreply@github.com>
Fri, 21 Jul 2023 20:28:22 +0000 (22:28 +0200)
commitd0176ed911e7c1717b21e276d1ff2c109e62356a
treef5da510bf99386b4b8026abf5c9372e61fcaab54
parent957f14d0decb7aa5723d5ed8c4d16abad40547b0
[3.12] gh-105699: Fix an Interned Strings Crasher (gh-106930) (#106963)

gh-105699: Fix an Interned Strings Crasher (gh-106930)

A static (process-global) str object must only have its "interned" state cleared when no longer interned in any interpreters.  They are the only ones that can be shared by interpreters so we don't have to worry about any other str objects.

We trigger clearing the state with the main interpreter, since no other interpreters may exist at that point and _PyUnicode_ClearInterned() is only called during interpreter finalization.

We do not address here the fact that a string will only be interned in the first interpreter that interns it.  In any subsequent interpreters str.state.interned is already set so _PyUnicode_InternInPlace() will skip it.  That needs to be addressed separately from fixing the crasher.
(cherry picked from commit 87e7cb09e4258c4deb01a07dc52c1021907195d7)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Misc/NEWS.d/next/Core and Builtins/2023-07-20-15-15-57.gh-issue-105699.DdqHFg.rst [new file with mode: 0644]
Objects/unicodeobject.c