You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang's thread safety analysis warns that it cannot handle "conditionally held locks" [1]. They give the example of:
bool b = needsToLock();
if (b) mu.Lock();
... // Warning! Mutex 'mu' is not held on every path through here.
if (b) mu.Unlock();
This is rather unfortunate, because phread_mutex_lock() is documented as being able to fail and set errno [2]. Well-written code will therefore not assume that the lock is successful, and will instead check the returned value and jump to error handling if necessary. In other words, well-written code will include "conditionally held locks".
Notes mainly to myself.
Clang's thread safety analysis warns that it cannot handle "conditionally held locks" [1]. They give the example of:
This is rather unfortunate, because
phread_mutex_lock()
is documented as being able to fail and seterrno
[2]. Well-written code will therefore not assume that the lock is successful, and will instead check the returned value and jump to error handling if necessary. In other words, well-written code will include "conditionally held locks".[1] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#conditional-locks
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_trylock.html
(BTW, we already have
-Wno-pthread-safety-analys
in spiped, for precisely this reason; the false warning arises from https://github.com/Tarsnap/spiped/blob/master/lib/dnsthread/dnsthread.c#L176)The text was updated successfully, but these errors were encountered: