diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-01 01:00:05 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-01 01:00:05 (GMT) |
commit | a4d4f1b4cb9f6038f865f86e1aa93169fc54dbaf (patch) | |
tree | ea85f9aa23be7e22cd66a62a9c8c4a69914901ce /Modules/faulthandler.c | |
parent | 1c76b7f5e505e370a5e0b840af3002054eda1e0c (diff) | |
download | cpython-a4d4f1b4cb9f6038f865f86e1aa93169fc54dbaf.zip cpython-a4d4f1b4cb9f6038f865f86e1aa93169fc54dbaf.tar.gz cpython-a4d4f1b4cb9f6038f865f86e1aa93169fc54dbaf.tar.bz2 |
Issue #11393: New try to fix faulthandler_thread()
Always release the cancel join.
Fix also another corner case: _PyFaulthandler_Fini() called after setting
running variable to zero, but before releasing the join lock.
Diffstat (limited to 'Modules/faulthandler.c')
-rw-r--r-- | Modules/faulthandler.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 760689e..f8b9fb6 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -401,7 +401,6 @@ faulthandler_thread(void *unused) thread.timeout_ms, 0); if (st == PY_LOCK_ACQUIRED) { /* Cancelled by user */ - PyThread_release_lock(thread.cancel_event); break; } /* Timeout => dump traceback */ @@ -418,8 +417,9 @@ faulthandler_thread(void *unused) } while (ok && thread.repeat); /* The only way out */ - thread.running = 0; + PyThread_release_lock(thread.cancel_event); PyThread_release_lock(thread.join_event); + thread.running = 0; } static void @@ -428,11 +428,11 @@ faulthandler_cancel_dump_tracebacks_later(void) if (thread.running) { /* Notify cancellation */ PyThread_release_lock(thread.cancel_event); - /* Wait for thread to join */ - PyThread_acquire_lock(thread.join_event, 1); - assert(thread.running == 0); - PyThread_release_lock(thread.join_event); } + /* Wait for thread to join */ + PyThread_acquire_lock(thread.join_event, 1); + assert(thread.running == 0); + PyThread_release_lock(thread.join_event); Py_CLEAR(thread.file); } |