https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4ec5ffc198fcdcbea2dbca81a337900ac33b1fa7
commit 4ec5ffc198fcdcbea2dbca81a337900ac33b1fa7 Author: Corinna Vinschen <[email protected]> Date: Fri Mar 8 12:51:10 2019 +0100 Cygwin: posix timers: fix a deadlock Canceling the timer thread runs under lock. The thread uses the same lock to guard its timer_tracker struct access. If the timing is bad, timer_settime or timer_delete grab the lock at the same time, the timer expires. In the end, cancel waits for the thread sync while the thread waits for ther lock to be released. Fix this by not waiting for the thread sync under lock. Signed-off-by: Corinna Vinschen <[email protected]> Diff: --- winsup/cygwin/posix_timer.cc | 2 ++ winsup/cygwin/release/3.0.3 | 3 +++ 2 files changed, 5 insertions(+) diff --git a/winsup/cygwin/posix_timer.cc b/winsup/cygwin/posix_timer.cc index a140b00..c0d548f 100644 --- a/winsup/cygwin/posix_timer.cc +++ b/winsup/cygwin/posix_timer.cc @@ -31,7 +31,9 @@ timer_tracker::cancel () SetEvent (cancel_evt); if (sync_thr) { + ReleaseSRWLockExclusive (&srwlock); res = WaitForSingleObject (sync_thr, INFINITE); + AcquireSRWLockExclusive (&srwlock); if (res != WAIT_OBJECT_0) debug_printf ("WFSO returned unexpected value %u, %E", res); } diff --git a/winsup/cygwin/release/3.0.3 b/winsup/cygwin/release/3.0.3 index 66ae639..b8c89cb 100644 --- a/winsup/cygwin/release/3.0.3 +++ b/winsup/cygwin/release/3.0.3 @@ -11,3 +11,6 @@ Bug Fixes - Fix a resource leak in posix timers. Addresses: https://cygwin.com/ml/cygwin/2019-03/msg00120.html + +- Fix a deadlock in posix timers + Addresses: https://cygwin.com/ml/cygwin/2019-03/msg00158.html
