]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 31 May 2024 15:29:50 +0000 (17:29 +0200)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 15:29:50 +0000 (15:29 +0000)
commitea48de4f4fadd7466c43ecaa88b431fc64b12acb
tree0ddf6162928fb41b4eb53ab9839e131ae66df0e3
parentd6faac6d1f825405398158272286aaed94eb51fc
[3.13] gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()` (GH-119753) (#119859)

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)

Co-authored-by: Sam Gross <colesbury@gmail.com>
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