Llvm thread sanitizer and qmutex
-
Hallo,
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.
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. If "data" is a global variable, the false warning is not shown also.What are the differences between the two mutex variants? Shouldn't both use pthread_mutex internally on a linux system? Are there any experiences in debugging Qt programs with llvm thread sanitizer?
Thanks in advance,
Benjamin@#include <QtConcurrentRun>
#include <QMutex>
#include <iostream>
#include <boost/thread/mutex.hpp>//int data;
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;
}@ -
Hi and welcome to devnet,
I would advise to bring this topic on the interest mailing list. You'll find there Qt's developers/maintainers (this forum is more user oriented)
-
Thanks for this tip. My question was answered on the interest mailing list:
http://lists.qt-project.org/pipermail/interest/2014-March/011479.html