Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-37402

QMutex not recognized by thread sanitizer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.6.2
    • Core: Threads
    • 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

      Attachments

        For Gerrit Dashboard: QTBUG-37402
        # Subject Branch Project Status CR V

        Activity

          People

            thiago Thiago Macieira
            wnt_bf Benjamin Firl
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes