[Python-checkins] cpython: Issue #11393: fix usage of locks in faulthandler

victor.stinner python-checkins at python.org
Fri Apr 1 03:17:36 CEST 2011


http://hg.python.org/cpython/rev/3558eecd84f0
changeset: 69097:3558eecd84f0
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Fri Apr 01 03:16:51 2011 +0200
summary:
 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
files:
 Modules/faulthandler.c | 7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -48,7 +48,7 @@
 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 @@
 /* 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 @@
 }
 /* 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 @@
 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");
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /