gh-96387: take_gil() resets drop request before exit (GH-96869) (GH-96941)
At Python exit, sometimes a thread holding the GIL can wait forever for a thread (usually a daemon thread) which requested to drop the GIL, whereas the thread already exited. To fix the race condition, the thread which requested the GIL drop now resets its request before exiting. take_gil() now calls RESET_GIL_DROP_REQUEST() before PyThread_exit_thread() if it called SET_GIL_DROP_REQUEST to fix a race condition with drop_gil(). Issue discovered and analyzed by Mingliang ZHAO. (cherry picked from commit 04f4977f508583954ad7b9cb09076ee1e57461f8) (cherry picked from commit 6ff54716f1073a4bcfed8a1ec0b518c489c1af0d) Co-authored-by: Victor Stinner <vstinner@python.org>
M
Miss Islington (bot) committed
dcff50a3e9a38302009263594b4485c49f51e853
Parent: 88a3f18
Committed by GitHub <noreply@github.com>
on 9/20/2022, 12:36:26 AM