summaryrefslogtreecommitdiffstats
path: root/Modules/faulthandler.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-01 01:16:51 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-01 01:16:51 (GMT)
commitf309134effa997b19e202c9b580d3332952f65a4 (patch)
tree2446a4709e8d8c0a90ca8ef32dcb027c5414d104 /Modules/faulthandler.c
parenta4d4f1b4cb9f6038f865f86e1aa93169fc54dbaf (diff)
downloadcpython-f309134effa997b19e202c9b580d3332952f65a4.zip
cpython-f309134effa997b19e202c9b580d3332952f65a4.tar.gz
cpython-f309134effa997b19e202c9b580d3332952f65a4.tar.bz2
Issue #11393: fix usage of locks in faulthandler
* faulthandler_cancel_dump_tracebacks_later() is responsible to set running to zero (so we don't need the volatile keyword anymore) * release locks if PyThread_start_new_thread() fails assert(thread.running == 0) was wrong in a corner case
Diffstat (limited to 'Modules/faulthandler.c')
-rw-r--r--Modules/faulthandler.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index f8b9fb6..6e3ed7c 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -48,7 +48,7 @@ static struct {
int fd;
PY_TIMEOUT_T timeout_ms; /* timeout in microseconds */
int repeat;
- volatile int running;
+ int running;
PyInterpreterState *interp;
int exit;
/* released by parent thread when cancel request */
@@ -419,7 +419,6 @@ faulthandler_thread(void *unused)
/* The only way out */
PyThread_release_lock(thread.cancel_event);
PyThread_release_lock(thread.join_event);
- thread.running = 0;
}
static void
@@ -431,8 +430,8 @@ faulthandler_cancel_dump_tracebacks_later(void)
}
/* Wait for thread to join */
PyThread_acquire_lock(thread.join_event, 1);
- assert(thread.running == 0);
PyThread_release_lock(thread.join_event);
+ thread.running = 0;
Py_CLEAR(thread.file);
}
@@ -486,6 +485,8 @@ faulthandler_dump_traceback_later(PyObject *self,
thread.running = 1;
if (PyThread_start_new_thread(faulthandler_thread, NULL) == -1) {
thread.running = 0;
+ PyThread_release_lock(thread.join_event);
+ PyThread_release_lock(thread.cancel_event);
Py_CLEAR(thread.file);
PyErr_SetString(PyExc_RuntimeError,
"unable to start watchdog thread");