[Issue 15939] GC.collect causes deadlock in multi-threaded environment
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Aug 9 09:46:07 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15939
--- Comment #18 from Martin Nowak <code at dawg.eu> ---
Think I just spotted the problem.
There seems to be a race condition between sending the signal and checking
whether the thread exited.
https://github.com/dlang/druntime/blob/c1f285715cf14e80307eafc76d0b25b417b8de19/src/core/thread.d#L2586-L2588
This might lead to a wrong counting of active threads, and therefor to a
deadlock.
https://github.com/dlang/druntime/blob/c1f285715cf14e80307eafc76d0b25b417b8de19/src/core/thread.d#L2648-L2649
Those changes were indeed introduced with
https://github.com/dlang/druntime/pull/1110.
A fix would be to simply synchronize the reception of the signal in
thread_suspendHandler with a variable in Thread, and only sem_wait for threads
that did receive the signal, somewhat similar to the FreeBSD workaround.
--
More information about the Digitalmars-d-bugs
mailing list