]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear...
authorSam Gross <colesbury@gmail.com>
Fri, 31 May 2024 15:42:09 +0000 (11:42 -0400)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 15:42:09 +0000 (15:42 +0000)
commit738cf216093e844c154f9ba36605f485fac5ff0d
tree0d8c7c81918c7e62cf540bd0d8e5a7fff5e2ef1c
parentd4680b9e17815140b512a399069400794dae1f97
[3.12] gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()` (GH-119753) (#119861)

Make sure that `gilstate_counter` is not zero in when calling
`PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may
call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If
`gilstate_counter` is zero, it will try to create a new thread state before
the current active thread state is destroyed, leading to an assertion failure
or crash.
(cherry picked from commit bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c)
Lib/test/test_capi/test_misc.py
Misc/NEWS.d/next/C API/2024-05-29-21-05-59.gh-issue-119585.Sn7JL3.rst [new file with mode: 0644]
Modules/_testcapimodule.c
Python/pystate.c