aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/patches/fix-segfault-with-pydebug.patch
blob: 3f6dd1c470f2e1b7dd83f42a2ea54ea310cf63bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
commit fc804aedfe1e844aaed4aa196830ca057f89361c (HEAD)
author: shadchin
date: 2024-02-07T11:13:39+03:00

    Fix segfault

--- contrib/tools/python3/Python/pystate.c	(bacb745829a9c01a81284c346946097c868084e0)
+++ contrib/tools/python3/Python/pystate.c	(fc804aedfe1e844aaed4aa196830ca057f89361c)
@@ -354,6 +354,11 @@ holds_gil(PyThreadState *tstate)
     // XXX Fall back to tstate->interp->runtime->ceval.gil.last_holder
     // (and tstate->interp->runtime->ceval.gil.locked).
     assert(tstate != NULL);
+#ifndef NDEBUG
+    if (!tstate_is_alive(tstate)) {
+        return PyGILState_Check();
+    }
+#endif
     _PyRuntimeState *runtime = tstate->interp->runtime;
     /* Must be the tstate for this thread */
     assert(tstate == gilstate_tss_get(runtime));