summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-20 00:36:26 (GMT)
committerGitHub <noreply@github.com>2022-09-20 00:36:26 (GMT)
commitdcff50a3e9a38302009263594b4485c49f51e853 (patch)
tree89f9b9d353a7056e3ad90f17f05667921608fe03 /Misc
parent88a3f1873ec4e6d35b1736c480c7087e01fca40f (diff)
downloadcpython-dcff50a3e9a38302009263594b4485c49f51e853.zip
cpython-dcff50a3e9a38302009263594b4485c49f51e853.tar.gz
cpython-dcff50a3e9a38302009263594b4485c49f51e853.tar.bz2
gh-96387: take_gil() resets drop request before exit (GH-96869) (GH-96941)
At Python exit, sometimes a thread holding the GIL can wait forever for a thread (usually a daemon thread) which requested to drop the GIL, whereas the thread already exited. To fix the race condition, the thread which requested the GIL drop now resets its request before exiting. take_gil() now calls RESET_GIL_DROP_REQUEST() before PyThread_exit_thread() if it called SET_GIL_DROP_REQUEST to fix a race condition with drop_gil(). Issue discovered and analyzed by Mingliang ZHAO. (cherry picked from commit 04f4977f508583954ad7b9cb09076ee1e57461f8) (cherry picked from commit 6ff54716f1073a4bcfed8a1ec0b518c489c1af0d) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2022-09-16-16-54-35.gh-issue-96387.GRzewg.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-09-16-16-54-35.gh-issue-96387.GRzewg.rst b/Misc/NEWS.d/next/Core and Builtins/2022-09-16-16-54-35.gh-issue-96387.GRzewg.rst
new file mode 100644
index 0000000..611ab94
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-09-16-16-54-35.gh-issue-96387.GRzewg.rst
@@ -0,0 +1,5 @@
+At Python exit, sometimes a thread holding the GIL can wait forever for a
+thread (usually a daemon thread) which requested to drop the GIL, whereas
+the thread already exited. To fix the race condition, the thread which
+requested the GIL drop now resets its request before exiting. Issue
+discovered and analyzed by Mingliang ZHAO. Patch by Victor Stinner.