[Interest] llvm thread sanitizer and qmutex
konrad at silmor.de
Wed Mar 5 16:01:13 CET 2014
On Wednesday, Wednesday 05 March 2014 at 14:50, Firl, Benjamin wrote:
> we make heavy use of Qt in our software and are now trying to use llvm
> thread sanitizer for debugging. Unfortunately the sanitizer doesn't seem
> to recognize QMutex as a locking mechanism.
That's because on Linux it does not use classic locking mechanisms - it uses
atomic operations on a memory location and futexes to wait on them and to wake
up other threads when freeing the mutex.
Valgrind is confused by this as well...
The upside of that implementation is that it is a lot faster, while being just
> The example below warns about
> a race condition because the member "data" is accessed in two threads. If
> you use a boost::mutex instead, the warning disappears.
Because boost likely uses pthread_mutex, which is recognized by almost all the
toolkits that analyze thread locking.
If you ever find out how to tell LLVM about QMutex - let me know. ;-)
> If "data" is a
> global variable, the false warning is also not shown.
I think you should report this as a bug to LLVM. There really is no difference
between protecting global and heap objects. So LLVM should display the same
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 490 bytes
Desc: This is a digitally signed message part.
More information about the Interest