Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Llvm thread sanitizer and qmutex
Forum Updated to NodeBB v4.3 + New Features

Llvm thread sanitizer and qmutex

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wnt_bf
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wnt_bf
        wrote on last edited by
        #3

        Thanks for this tip. My question was answered on the interest mailing list:
        http://lists.qt-project.org/pipermail/interest/2014-March/011479.html

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved