https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89417

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Closing, because this is not a bug. Helgrind is warning about something that
isn't a problem. The order the locks are acquired by std::lock is unspecified,
so that the implementation can guarantee no deadlock. The current std::lock
just tries to lock each argument in order, but I'm about to commit a new
implementation which can rotate the arguments before locking them. For such an
implementation, there is no way the destructor of std::scoped_lock can possibly
know in which order the locks were acquired.

Since all the unlocks happen at the same time, one after another, the window of
time where some are unlocked and the others are still locked is small anyway.
And by using std::scoped_lock to lock and unlock, deadlock avoidance is
guaranteed.

You should suppress or ignore the helgrind warnings about this usage.

Reply via email to