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.
This commit is contained in:
parent
1c76b7f5e5
commit
a4d4f1b4cb
|
@ -401,7 +401,6 @@ faulthandler_thread(void *unused)
|
||||||
thread.timeout_ms, 0);
|
thread.timeout_ms, 0);
|
||||||
if (st == PY_LOCK_ACQUIRED) {
|
if (st == PY_LOCK_ACQUIRED) {
|
||||||
/* Cancelled by user */
|
/* Cancelled by user */
|
||||||
PyThread_release_lock(thread.cancel_event);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Timeout => dump traceback */
|
/* Timeout => dump traceback */
|
||||||
|
@ -418,8 +417,9 @@ faulthandler_thread(void *unused)
|
||||||
} while (ok && thread.repeat);
|
} while (ok && thread.repeat);
|
||||||
|
|
||||||
/* The only way out */
|
/* The only way out */
|
||||||
thread.running = 0;
|
PyThread_release_lock(thread.cancel_event);
|
||||||
PyThread_release_lock(thread.join_event);
|
PyThread_release_lock(thread.join_event);
|
||||||
|
thread.running = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -428,11 +428,11 @@ faulthandler_cancel_dump_tracebacks_later(void)
|
||||||
if (thread.running) {
|
if (thread.running) {
|
||||||
/* Notify cancellation */
|
/* Notify cancellation */
|
||||||
PyThread_release_lock(thread.cancel_event);
|
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);
|
Py_CLEAR(thread.file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue