theRockLiu / thread-sanitizer

Automatically exported from code.google.com/p/thread-sanitizer
0 stars 0 forks source link

tsan does not recognize QMutex #53

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Compile and run the test program below.

What is the expected output? What do you see instead?

Tsan should recognize the QMutex as a synchronizing mechanism and not print a 
warning. The example works like expected using ab boost:mutex instead.

What version of the product are you using? On what operating system?

llvm-3.4 on centos-6.5 x86_64

Please provide any additional information below.

    #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;
    }

Original issue reported on code.google.com by benjamin...@wincor-nixdorf.com on 10 Mar 2014 at 1:10

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for the report.

Does QT accept patches from community?

Please also file an issue against QT. Let's see what interest are there.

Original comment by dvyu...@google.com on 11 Mar 2014 at 6:08

GoogleCodeExporter commented 9 years ago
The Qt bug report was closed because it's "not our issue": 
https://bugreports.qt.io/browse/QTBUG-37402

However they do accept patches if someone is able to fix the issue in the way 
they want you to...

Original comment by cbpar...@gmail.com on 2 Feb 2015 at 8:37