On 3/11/22 17:04, Henri Verbeet wrote:
This is largely the same as the condition variable implementation in ntdll. There are essentially two reasons for doing this:
- RtlWaitOnAddress() avoids server calls, compared to the existing keyed event implementation. - The NtReleaseKeyedEvent() call in _Cnd_signal() can hang if a thread was killed inside _Cnd_wait(), for example by an application calling exit(). Piotr Caban reports this scenario is supposed to work with msvcp140, although not necessarily with earlier versions of msvcp. (And indeed, native msvcp140 is a workaround for the affected applications.)
I've sent a set of patches that tries to fix it differently. It's using _Condition_variable to implement _Cnd_* functions in msvcp110/msvcp120. In msvcp140 CONDITION_VARIABLE and SRWLock is used instead.
It should fix the problem you're describing in msvcp140. _Condition_variable implementation is still to be fixed (currently Wine's implementation hangs while native crashes).
Thanks, Piotr