[Mingw-w64-public] [PATCH 2/2] winpthreads/cond.c: Do not wait for `sema_b` unless `waiters_count_lock_` has been locked in wait functions.

2019-04-26 Thread Liu Hao
All other functions wait for `sema_b` with `waiters_count_lock_` locked. The order of acquisition of these two things must happen in the same order in all functions, otherwise deadlocks may happen. The obvious fix is to make wait functions wait for the semaphore after having locked `waiters_count_

Re: [Mingw-w64-public] [PATCH] Fix potential deadlock in pthread condition variable

2019-04-26 Thread Liu Hao
在 2019/4/12 9:49, Andrew Ng 写道: > I have attached a minimal patch that fixes the deadlock issue. > > The principle change to avoid deadlock, is to not wait whilst holding > the "waiters count lock". Because of this change to the locking, there > is an additional case required in the "signal" and "

[Mingw-w64-public] [PATCH 1/2] winpthreads/cond.c: Only update `waiters_count_` when `waiters_count_lock_` is locked.

2019-04-26 Thread Liu Hao
Signed-off-by: Liu Hao --- mingw-w64-libraries/winpthreads/src/cond.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mingw-w64-libraries/winpthreads/src/cond.c b/mingw-w64-libraries/winpthreads/src/cond.c index 368ee8a7..8df395eb 100644 --- a/mingw-w64-libraries/winpthreads/src/cond.c +++