]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()...
authorSam Gross <colesbury@gmail.com>
Fri, 31 May 2024 14:50:52 +0000 (10:50 -0400)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 14:50:52 +0000 (10:50 -0400)
commitbcc1be39cb1d04ad9fc0bd1b9193d3972835a57c
tree74444fcc18034b396ec249de8f9735441f4338da
parent891c1e36f4e08da107443772a4eb50c72a83836d
gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()` (#119753)

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.
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