]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)
authorVictor Stinner <vstinner@python.org>
Mon, 1 Jun 2020 18:34:15 +0000 (20:34 +0200)
committerGitHub <noreply@github.com>
Mon, 1 Jun 2020 18:34:15 +0000 (20:34 +0200)
PyOS_InterruptOccurred() now fails with a fatal error if it is called
with the GIL released.

Misc/NEWS.d/next/C API/2020-06-01-16-12-37.bpo-40826.zQzFoK.rst [new file with mode: 0644]
Modules/signalmodule.c

diff --git a/Misc/NEWS.d/next/C API/2020-06-01-16-12-37.bpo-40826.zQzFoK.rst b/Misc/NEWS.d/next/C API/2020-06-01-16-12-37.bpo-40826.zQzFoK.rst
new file mode 100644 (file)
index 0000000..0d7a36c
--- /dev/null
@@ -0,0 +1,2 @@
+:c:func:`PyOS_InterruptOccurred` now fails with a fatal error if it is
+called with the GIL released.
index 8348971c353ba757a79bb30827d8c579292856bf..6d340a68634afc84778363cb76e14600f4bd8884 100644 (file)
@@ -1782,8 +1782,9 @@ PyOS_FiniInterrupts(void)
 int
 PyOS_InterruptOccurred(void)
 {
-    PyInterpreterState *interp = _PyInterpreterState_GET();
-    if (!_Py_ThreadCanHandleSignals(interp)) {
+    PyThreadState *tstate = _PyThreadState_GET();
+    _Py_EnsureTstateNotNULL(tstate);
+    if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
         return 0;
     }