Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
4.6.2
-
None
-
centos-6.5 x86_64
Description
Thread sanitizer can't detect QMutex as a synchronizing mechanism. This can be demonstrated with a test program:
#include <QtConcurrentRun> #include <QMutex> #include <iostream> #include <boost/thread/mutex.hpp> class TestClass { public: void fun() { QMutexLocker autoMutex(&mutex); //boost::mutex::scoped_lock bautoMutex(bmutex); data = 1; } private: int data; QMutex mutex; boost::mutex bmutex; }; int main() { TestClass *tc = new TestClass; QFuture<void> t1 = QtConcurrent::run(tc, &TestClass::fun); QFuture<void> t2 = QtConcurrent::run(tc, &TestClass::fun); t1.waitForFinished(); t2.waitForFinished(); return 0; }
The thread sanitizer will print a false warning about access to "data". Using boost::mutex instead, the example works as expected.
I also filled a thread sanitizer bug about this:
http://code.google.com/p/thread-sanitizer/issues/detail?id=53