diff options
author | Sam Gross <colesbury@gmail.com> | 2024-05-31 14:50:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-31 14:50:52 (GMT) |
commit | bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c (patch) | |
tree | 74444fcc18034b396ec249de8f9735441f4338da /Misc/NEWS.d/next/C API | |
parent | 891c1e36f4e08da107443772a4eb50c72a83836d (diff) | |
download | cpython-bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c.zip cpython-bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c.tar.gz cpython-bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c.tar.bz2 |
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.
Diffstat (limited to 'Misc/NEWS.d/next/C API')
-rw-r--r-- | Misc/NEWS.d/next/C API/2024-05-29-21-05-59.gh-issue-119585.Sn7JL3.rst | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/C API/2024-05-29-21-05-59.gh-issue-119585.Sn7JL3.rst b/Misc/NEWS.d/next/C API/2024-05-29-21-05-59.gh-issue-119585.Sn7JL3.rst new file mode 100644 index 0000000..038dec2 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2024-05-29-21-05-59.gh-issue-119585.Sn7JL3.rst @@ -0,0 +1,5 @@ +Fix crash when a thread state that was created by :c:func:`PyGILState_Ensure` +calls a destructor that during :c:func:`PyThreadState_Clear` that +calls back into :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`. +This might occur when in the free-threaded build or when using thread-local +variables whose destructors call :c:func:`PyGILState_Ensure`. |