]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-105699: Fix an Interned Strings Crasher (gh-106930)
authorEric Snow <ericsnowcurrently@gmail.com>
Fri, 21 Jul 2023 14:32:42 +0000 (08:32 -0600)
committerGitHub <noreply@github.com>
Fri, 21 Jul 2023 14:32:42 +0000 (08:32 -0600)
commit87e7cb09e4258c4deb01a07dc52c1021907195d7
tree28d13e984c410e92e89e8ed3c812a8de10fe3f9d
parentfd84ac0ee0a8d5e34e0a106eed7e50539b61c5f8
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.
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