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

Data race in QMutexPool

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.9.9, 5.12.5, 5.14.0 Alpha, 5.14
    • 5.8
    • Network: SSL
    • None
    • clang version 3.9.1 (tags/RELEASE_391/final 289600)
      Linux, X11, qtbase from git 5.8
    • da38f0d691d9d7eacfac5fbcbd47b887bd59bd39 65b8f59e045bb41fef99b1a44f462115de65064a 787e498487831c55be89979824709622ba29f17c (qt/qtbase/5.12)

    Description

      Using QNAM in two threads shows this data race, when compiled with clang+tsan:

      WARNING: ThreadSanitizer: data race (pid=8511)
        Atomic write of size 8 at 0x7d040000b760 by thread T9:
          #0 __tsan_atomic64_compare_exchange_val /home/abuild/rpmbuild/BUILD/llvm-3.9.1.src/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:826:3 (convertertest+0x000000487e3a)
          #1 std::__1::__atomic_base<QMutexData*, false>::compare_exchange_strong(QMutexData*&, QMutexData*, std::__1::memory_order) /usr/bin/../include/c++/v1/atomic:936:17 (libQt5Core.so.5+0x0000000e4660)
          #2 bool QAtomicOps<QMutexData*>::testAndSetAcquire<QMutexData*>(std::__1::atomic<QMutexData*>&, QMutexData*, QMutexData*, QMutexData**) /d/qt/5/kdab/qtbase-dev/build/src/corelib/../../include/QtCore/../../../src/corelib/arch/qatomic_cxx11.h:290 (libQt5Core.so.5+0x0000000e4660)
          #3 QBasicAtomicPointer<QMutexData>::testAndSetAcquire(QMutexData*, QMutexData*, QMutexData*&) /d/qt/5/kdab/qtbase-dev/build/src/corelib/../../include/QtCore/../../../src/corelib/thread/qbasicatomic.h:262:14 (libQt5Core.so.5+0x0000000e4308)
          #4 QBasicMutex::fastTryLock(QMutexData*&) /d/qt/5/kdab/qtbase-dev/build/src/corelib/../../include/QtCore/../../../src/corelib/thread/qmutex.h:101:22 (libQt5Core.so.5+0x0000000e3e36)
          #5 QMutex::lock() /d/qt/5/kdab/qtbase-dev/src/corelib/thread/qmutex.cpp:224:9 (libQt5Core.so.5+0x0000000e31d6)
          #6 QMutexLocker::QMutexLocker(QBasicMutex*) /d/qt/5/kdab/qtbase-dev/build/src/network/../../include/QtCore/../../../src/corelib/thread/qmutex.h:200:39 (libQt5Network.so.5+0x0000000a0b80)
          #7 q_resolveOpenSslSymbols() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl_symbols.cpp:763:18 (libQt5Network.so.5+0x00000026158b)
          #8 QSslSocketPrivate::ensureLibraryLoaded() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl.cpp:534:10 (libQt5Network.so.5+0x00000024e055)
          #9 QSslSocketPrivate::supportsSsl() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl.cpp:529:12 (libQt5Network.so.5+0x00000024e025)
          #10 QSslSocketPrivate::ensureInitialized() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl.cpp:627:10 (libQt5Network.so.5+0x00000024c601)
          #11 QSslCertificatePrivate::QSslCertificatePrivate() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslcertificate_p.h:86:9 (libQt5Network.so.5+0x000000224c4e)
          #12 QSslCertificate::QSslCertificate(QByteArray const&, QSsl::EncodingFormat) /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslcertificate.cpp:157:13 (libQt5Network.so.5+0x000000223704)
          #13 QSslConfigurationPrivate::QSslConfigurationPrivate() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslconfiguration_p.h:84:5 (libQt5Network.so.5+0x000000228706)
          #14 QSslConfiguration::QSslConfiguration() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslconfiguration.cpp:156:13 (libQt5Network.so.5+0x00000022692f)
          #15 QNetworkReplyHttpImplPrivate::QNetworkReplyHttpImplPrivate() /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkreplyhttpimpl.cpp:426:31 (libQt5Network.so.5+0x0000000e90c9)
          #16 QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager*, QNetworkRequest const&, QNetworkAccessManager::Operation&, QIODevice*) /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkreplyhttpimpl.cpp:172:26 (libQt5Network.so.5+0x0000000e555b)
          #17 QNetworkAccessManager::createRequest(QNetworkAccessManager::Operation, QNetworkRequest const&, QIODevice*) /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkaccessmanager.cpp:1410:44 (libQt5Network.so.5+0x0000000a75b7)
          #18 QNetworkAccessManager::get(QNetworkRequest const&) /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkaccessmanager.cpp:808:34 (libQt5Network.so.5+0x0000000a48bc)
      
        Previous write of size 8 at 0x7d040000b760 by thread T3:
          #0 operator new(unsigned long) /home/abuild/rpmbuild/BUILD/llvm-3.9.1.src/projects/compiler-rt/lib/tsan/rtl/tsan_new_delete.cc:41:3 (convertertest+0x0000004a1742)
          #1 QMutexPool::createMutex(int) /d/qt/5/kdab/qtbase-dev/src/corelib/thread/qmutexpool.cpp:133:24 (libQt5Core.so.5+0x0000000ed0df)
          #2 QMutexPool::get(void const*) /d/qt/5/kdab/qtbase-dev/src/corelib/thread/qmutexpool_p.h:75:20 (libQt5Core.so.5+0x0000000eda21)
          #3 QMutexPool::globalInstanceGet(void const*) /d/qt/5/kdab/qtbase-dev/src/corelib/thread/qmutexpool.cpp:147:28 (libQt5Core.so.5+0x0000000ed214)
          #4 q_resolveOpenSslSymbols() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl_symbols.cpp:763:25 (libQt5Network.so.5+0x00000026157f)
          #5 QSslSocketPrivate::ensureLibraryLoaded() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl.cpp:534:10 (libQt5Network.so.5+0x00000024e055)
          #6 QSslSocketPrivate::supportsSsl() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl.cpp:529:12 (libQt5Network.so.5+0x00000024e025)
          #7 QSslSocketPrivate::ensureInitialized() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl.cpp:627:10 (libQt5Network.so.5+0x00000024c601)
          #8 QSslCertificatePrivate::QSslCertificatePrivate() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslcertificate_p.h:86:9 (libQt5Network.so.5+0x000000224c4e)
          #9 QSslCertificate::QSslCertificate(QByteArray const&, QSsl::EncodingFormat) /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslcertificate.cpp:157:13 (libQt5Network.so.5+0x000000223704)
          #10 QSslConfigurationPrivate::QSslConfigurationPrivate() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslconfiguration_p.h:84:5 (libQt5Network.so.5+0x000000228706)
          #11 QSslConfiguration::QSslConfiguration() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslconfiguration.cpp:156:13 (libQt5Network.so.5+0x00000022692f)
          #12 QNetworkReplyHttpImplPrivate::QNetworkReplyHttpImplPrivate() /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkreplyhttpimpl.cpp:426:31 (libQt5Network.so.5+0x0000000e90c9)
          #13 QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager*, QNetworkRequest const&, QNetworkAccessManager::Operation&, QIODevice*) /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkreplyhttpimpl.cpp:172:26 (libQt5Network.so.5+0x0000000e555b)
          #14 QNetworkAccessManager::createRequest(QNetworkAccessManager::Operation, QNetworkRequest const&, QIODevice*) /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkaccessmanager.cpp:1410:44 (libQt5Network.so.5+0x0000000a75b7)
          #15 QNetworkAccessManager::get(QNetworkRequest const&) /d/qt/5/kdab/qtbase-dev/src/network/access/qnetworkaccessmanager.cpp:808:34 (libQt5Network.so.5+0x0000000a48bc)
      
        Location is heap block of size 8 at 0x7d040000b760 allocated by thread T3:
          #0 operator new(unsigned long) /home/abuild/rpmbuild/BUILD/llvm-3.9.1.src/projects/compiler-rt/lib/tsan/rtl/tsan_new_delete.cc:41:3 (convertertest+0x0000004a1742)
          #1 QMutexPool::createMutex(int) /d/qt/5/kdab/qtbase-dev/src/corelib/thread/qmutexpool.cpp:133:24 (libQt5Core.so.5+0x0000000ed0df)
          #2 QMutexPool::get(void const*) /d/qt/5/kdab/qtbase-dev/src/corelib/thread/qmutexpool_p.h:75:20 (libQt5Core.so.5+0x0000000eda21)
          #3 QMutexPool::globalInstanceGet(void const*) /d/qt/5/kdab/qtbase-dev/src/corelib/thread/qmutexpool.cpp:147:28 (libQt5Core.so.5+0x0000000ed214)
          #4 q_resolveOpenSslSymbols() /d/qt/5/kdab/qtbase-dev/src/network/ssl/qsslsocket_openssl_symbols.cpp:763:25 (libQt5Network.so.5+0x00000026157f)
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mmutz Marc Mutz
            dfaure_kdab David Faure
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes