[PATCH] D109914: [Support] Attempt to fix deadlock in ThreadGroup

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 17 08:50:42 PDT 2021


aganea added a comment.

Could you please take a second look?

I've removed the change to `std::condition_variable::notify_all()` because it was introducing a new issue, where the `Latch` object would be destroyed in-between the release of the mutex in `Latch::dec()` and the call to `notify_all()` in the same function. This is probably because the sleeping thread was awaken spuriously before `notify_all()` was even called, like mentioned here:

https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-sleepconditionvariablecs

> Condition variables are subject to spurious wakeups (those not associated with an explicit wake) and stolen wakeups (another thread manages to run before the woken thread). Therefore, you should recheck a predicate (typically in a while loop) after a sleep operation returns.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109914/new/

https://reviews.llvm.org/D109914



More information about the llvm-commits mailing list