]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-59956: Partial Fix for GILState API Compatibility with Subinterpreters (gh-101431)
authorEric Snow <ericsnowcurrently@gmail.com>
Mon, 6 Feb 2023 21:39:25 +0000 (14:39 -0700)
committerGitHub <noreply@github.com>
Mon, 6 Feb 2023 21:39:25 +0000 (14:39 -0700)
commit132b3f8302c021ac31e9c1797a127d57faa1afee
treecd79634eca0a8d381f1ce76df83da94c5df7d4fe
parent262003fd3297f7f4ee09cebd1abb225066412ce7
gh-59956: Partial Fix for GILState API Compatibility with Subinterpreters (gh-101431)

The GILState API (PEP 311) implementation from 2003 made the assumption that only one thread state would ever be used for any given OS thread, explicitly disregarding the case of subinterpreters.  However, PyThreadState_Swap() still facilitated switching between subinterpreters, meaning the "current" thread state (holding the GIL), and the GILState thread state could end up out of sync, causing problems (including crashes).

This change addresses the issue by keeping the two in sync in PyThreadState_Swap().  I verified the fix against gh-99040.

Note that the other GILState-subinterpreter incompatibility (with autoInterpreterState) is not resolved here.

https://github.com/python/cpython/issues/59956
Misc/NEWS.d/next/Core and Builtins/2023-01-30-11-56-09.gh-issue-59956.7xqnC_.rst [new file with mode: 0644]
Python/pystate.c