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

QQmlComponent::setData crashes sporadically when called from multiple threads

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P1: Critical
    • Resolution: Unresolved
    • Affects Version/s: 5.12.0
    • Fix Version/s: None
    • Labels:
    • Environment:
      linux kernel 4.20
      archlinux
    • Platform/s:
      Linux/X11

      Description

      The code below crashes sporadically with a SEGFAULT in qt release version (~one out of seven runs failes).

      In debug version, the program fails due to asserts.

      #include <QThread>
      #include <QCoreApplication>
      #include <QtQml/QQmlEngine>
      #include <QtQml/QQmlComponent>
      #include <atomic>
      
      int main(int argc, char *argv[])
      {
          std::atomic<int> runningThreads{3};
          QCoreApplication a(argc, argv);
      
          for(int i=0; i<3; ++i){
              auto thread = new QThread;
              thread->moveToThread(thread);
              thread->start();
      
              // used to exit application after threads done
              QObject::connect(thread, &QThread::finished, [&]{
                  if(--runningThreads == 0)
                      QCoreApplication::exit();
              });
      
              QMetaObject::invokeMethod(thread, [thread]{
                  auto qmlEngine = new QQmlEngine(thread);
                  auto component = new QQmlComponent(qmlEngine, thread);
                  component->setData(QByteArray{"import QtQuick 2.0\nQtObject {}\n"}, {"Script"});
                  thread->quit();
              }, Qt::QueuedConnection);
          }
          return a.exec();
      }
      

      We encountered multiple assert failures:

      ASSERT failure in QArrayData::deallocate: "Static data can not be deleted", file tools/qarraydata.cpp, line 166
      
      stacktrace:
      #0  0x00007fac8acc2d7f in raise () from /usr/lib/libc.so.6
      #1  0x00007fac8acad672 in abort () from /usr/lib/libc.so.6
      #2  0x00007fac8b25e236 in ?? () from /usr/lib/libQt5Core.so.5
      #3  0x00007fac8b25a330 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/libQt5Core.so.5
      #4  0x00007fac8b251471 in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib/libQt5Core.so.5
      #5  0x00007fac8b27db90 in QArrayData::deallocate(QArrayData*, unsigned long, unsigned long) () from /usr/lib/libQt5Core.so.5
      #6  0x00007fac8bb9a973 in QTypedArrayData<char>::deallocate (data=0x7fac6c0068b0) at /usr/include/qt/QtCore/qarraydata.h:239
      #7  0x00007fac8bb99ee1 in QByteArray::~QByteArray (this=0x7fac855e6ea0, __in_chrg=<optimized out>) at /usr/include/qt/QtCore/qbytearray.h:476
      #8  0x00007fac8bebc3ce in QQmlPropertyCache::checksum (this=0x7fac7004c8b0, ok=0x7fac855e6f37)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmlpropertycache.cpp:1474
      #9  0x00007fac8bebc31d in QQmlPropertyCache::checksum (this=0x7fac7004cce0, ok=0x7fac855e6f37)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmlpropertycache.cpp:1464
      #10 0x00007fac8bbe1248 in QV4::CompiledData::ResolvedTypeReference::addToHash (this=0x7fac7004c880, hash=0x7fac855e7108, engine=0x7fac78004ab0)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/compiler/qv4compileddata.cpp:831
      #11 0x00007fac8bbe143e in QV4::CompiledData::ResolvedTypeReferenceMap::addToHash (this=0x7fac7004cbf8, hash=0x7fac855e7108, engine=0x7fac78004ab0)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/compiler/qv4compileddata.cpp:863
      #12 0x00007fac8be8ee75 in QQmlTypeData::<lambda(QCryptographicHash*)>::operator()(QCryptographicHash *) const (__closure=0x7fac7004cbf0, hash=0x7fac855e7108)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:2352
      #13 0x00007fac8be96633 in std::_Function_handler<bool(QCryptographicHash*), QQmlTypeData::done()::<lambda(QCryptographicHash*)> >::_M_invoke(const std::_Any_data &, QCryptographicHash *&&) (__functor=..., 
          __args#0=@0x7fac855e7010: 0x7fac855e7108) at /usr/include/c++/8.2.1/bits/std_function.h:282
      #14 0x00007fac8bbe50ed in std::function<bool (QCryptographicHash*)>::operator()(QCryptographicHash*) const (this=0x7fac855e7690, __args#0=0x7fac855e7108) at /usr/include/c++/8.2.1/bits/std_function.h:687
      #15 0x00007fac8bc2c755 in QmlIR::QmlUnitGenerator::generate(QmlIR::Document&, std::function<bool (QCryptographicHash*)> const&) (this=0x7fac855e7300, output=..., dependencyHasher=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/compiler/qqmlirbuilder.cpp:1591
      #16 0x00007fac8bc63c35 in QQmlTypeCompiler::compile (this=0x7fac855e7500) at qtdeclarative-everywhere-src-5.12.0/src/qml/compiler/qqmltypecompiler.cpp:161
      #17 0x00007fac8be91a8b in QQmlTypeData::compile(QQmlRefPointer<QQmlTypeNameCache> const&, QV4::CompiledData::ResolvedTypeReferenceMap const&, std::function<bool (QCryptographicHash*)> const&) (
          this=0x7fac7803ecd0, typeNameCache=..., resolvedTypeCache=..., dependencyHasher=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:2650
      #18 0x00007fac8be8fc27 in QQmlTypeData::done (this=0x7fac7803ecd0) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:2368
      #19 0x00007fac8be88270 in QQmlDataBlob::tryDone (this=0x7fac7803ecd0) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:675
      #20 0x00007fac8be89d4f in QQmlTypeLoader::setData (this=0x7fac78004c20, blob=0x7fac7803ecd0, d=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:1312
      #21 0x00007fac8be89b0c in QQmlTypeLoader::setData (this=0x7fac78004c20, blob=0x7fac7803ecd0, data=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:1284
      #22 0x00007fac8be890f5 in QQmlTypeLoader::loadWithStaticDataThread (this=0x7fac78004c20, blob=0x7fac7803ecd0, data=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:1120
      #23 0x00007fac8be88cab in QQmlTypeLoaderThread::loadWithStaticDataThread (this=0x7fac78004e90, b=0x7fac7803ecd0, d=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:911
      #24 0x00007fac8be9b312 in QQmlThread::callMethodInThread<QQmlDataBlob*, QByteArray, QQmlDataBlob*, QByteArray const&, QQmlTypeLoaderThread>(void (QQmlTypeLoaderThread::*)(QQmlDataBlob*, QByteArray const&), QQmlDataBlob* const&, QByteArray const&)::I::call(QQmlThread*) (this=0x7fac7803ef20, thread=0x7fac78004e90)
          at qtdeclarative-everywhere-src-5.12.0/include/QtQml/5.12.0/QtQml/private/../../../../../src/qml/qml/ftw/qqmlthread_p.h:180
      #25 0x00007fac8bf27be5 in QQmlThreadPrivate::threadEvent (this=0x7fac780050b0) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/ftw/qqmlthread.cpp:197
      #26 0x00007fac8bf27966 in QQmlThreadPrivate::event (this=0x7fac780050b0, e=0x7fac7803ef60)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/ftw/qqmlthread.cpp:135
      #27 0x00007fac8b4b8b96 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #28 0x00007fac8b4b87c5 in ?? () from /usr/lib/libQt5Core.so.5
      #29 0x00007fac8b4b8728 in QCoreApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #30 0x00007fac8b4b8649 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #31 0x00007fac8b4b903a in QCoreApplication::sendEvent(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #32 0x00007fac8b4b9c63 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5
      #33 0x00007fac8b4b95c2 in QCoreApplication::sendPostedEvents(QObject*, int) () from /usr/lib/libQt5Core.so.5
      #34 0x00007fac8b54802d in ?? () from /usr/lib/libQt5Core.so.5
      #35 0x00007fac88674a2f in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
      #36 0x00007fac886765e9 in ?? () from /usr/lib/libglib-2.0.so.0
      #37 0x00007fac8867662e in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
      #38 0x00007fac8b5487fe in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #39 0x00007fac8b4b4eb3 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #40 0x00007fac8b4b51ed in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #41 0x00007fac8b26524f in QThread::exec() () from /usr/lib/libQt5Core.so.5
      #42 0x00007fac8bf279d7 in QQmlThreadPrivate::run (this=0x7fac780050b0) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/ftw/qqmlthread.cpp:148
      #43 0x00007fac8b267fc4 in ?? () from /usr/lib/libQt5Core.so.5
      #44 0x00007fac8b186a9d in start_thread () from /usr/lib/libpthread.so.0
      #45 0x00007fac8ad86b23 in clone () from /usr/lib/libc.so.6
      ASSERT: "data->notFullyResolved()" in file qqmlpropertycache.cpp, line 670
      stacktrace:
      #0  0x00007f887c49ed7f in raise () from /usr/lib/libc.so.6
      #1  0x00007f887c489672 in abort () from /usr/lib/libc.so.6
      #2  0x00007f887ca3a236 in ?? () from /usr/lib/libQt5Core.so.5
      #3  0x00007f887ca36330 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/libQt5Core.so.5
      #4  0x00007f887ca2d406 in qt_assert(char const*, char const*, int) () from /usr/lib/libQt5Core.so.5
      #5  0x00007f887d695ff8 in QQmlPropertyCache::resolve (this=0x7f885c04c220, data=0x7f885c04f068)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmlpropertycache.cpp:670
      #6  0x00007f887d40d558 in QQmlPropertyCache::ensureResolved (this=0x7f885c04c220, p=0x7f885c04f068)
          at qtdeclarative-everywhere-src-5.12.0/include/QtQml/5.12.0/QtQml/private/../../../../../src/qml/qml/qqmlpropertycache_p.h:728
      #7  0x00007f887d696961 in QQmlPropertyCache::findProperty (this=0x7f885c04c220, it=..., vmemo=0x0, context=0x0)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmlpropertycache.cpp:849
      #8  0x00007f887d6966cf in QQmlPropertyCache::findProperty (this=0x7f885c04c220, it=..., object=0x0, context=0x0)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmlpropertycache.cpp:782
      #9  0x00007f887d411329 in QQmlPropertyCache::property<QString> (this=0x7f885c04c220, key=..., object=0x0, context=0x0)
          at qtdeclarative-everywhere-src-5.12.0/include/QtQml/5.12.0/QtQml/private/../../../../../src/qml/qml/qqmlpropertycache_p.h:433
      #10 0x00007f887d694d61 in QQmlPropertyCache::defaultProperty (this=0x7f885c04c220)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmlpropertycache.cpp:433
      #11 0x00007f887d443228 in QQmlAliasAnnotator::annotateBindingsToAliases (this=0x7f88775c4330)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/compiler/qqmltypecompiler.cpp:731
      #12 0x00007f887d43f8a7 in QQmlTypeCompiler::compile (this=0x7f88775c4500) at qtdeclarative-everywhere-src-5.12.0/src/qml/compiler/qqmltypecompiler.cpp:117
      #13 0x00007f887d66da8b in QQmlTypeData::compile(QQmlRefPointer<QQmlTypeNameCache> const&, QV4::CompiledData::ResolvedTypeReferenceMap const&, std::function<bool (QCryptographicHash*)> const&) (
          this=0x7f886803cb50, typeNameCache=..., resolvedTypeCache=..., dependencyHasher=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:2650
      #14 0x00007f887d66bc27 in QQmlTypeData::done (this=0x7f886803cb50) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:2368
      #15 0x00007f887d664270 in QQmlDataBlob::tryDone (this=0x7f886803cb50) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:675
      #16 0x00007f887d665d4f in QQmlTypeLoader::setData (this=0x7f8868004c20, blob=0x7f886803cb50, d=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:1312
      #17 0x00007f887d665b0c in QQmlTypeLoader::setData (this=0x7f8868004c20, blob=0x7f886803cb50, data=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:1284
      #18 0x00007f887d6650f5 in QQmlTypeLoader::loadWithStaticDataThread (this=0x7f8868004c20, blob=0x7f886803cb50, data=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:1120
      #19 0x00007f887d664cab in QQmlTypeLoaderThread::loadWithStaticDataThread (this=0x7f8868004e90, b=0x7f886803cb50, d=...)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/qqmltypeloader.cpp:911
      #20 0x00007f887d677312 in QQmlThread::callMethodInThread<QQmlDataBlob*, QByteArray, QQmlDataBlob*, QByteArray const&, QQmlTypeLoaderThread>(void (QQmlTypeLoaderThread::*)(QQmlDataBlob*, QByteArray const&), QQmlDataBlob* const&, QByteArray const&)::I::call(QQmlThread*) (this=0x7f886803ccb0, thread=0x7f8868004e90)
          at qtdeclarative-everywhere-src-5.12.0/include/QtQml/5.12.0/QtQml/private/../../../../../src/qml/qml/ftw/qqmlthread_p.h:180
      #21 0x00007f887d703be5 in QQmlThreadPrivate::threadEvent (this=0x7f8868005150) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/ftw/qqmlthread.cpp:197
      #22 0x00007f887d703966 in QQmlThreadPrivate::event (this=0x7f8868005150, e=0x7f886803ccf0)
          at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/ftw/qqmlthread.cpp:135
      #23 0x00007f887cc94b96 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #24 0x00007f887cc947c5 in ?? () from /usr/lib/libQt5Core.so.5
      #25 0x00007f887cc94728 in QCoreApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #26 0x00007f887cc94649 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #27 0x00007f887cc9503a in QCoreApplication::sendEvent(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #28 0x00007f887cc95c63 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5
      #29 0x00007f887cc955c2 in QCoreApplication::sendPostedEvents(QObject*, int) () from /usr/lib/libQt5Core.so.5
      #30 0x00007f887cd2402d in ?? () from /usr/lib/libQt5Core.so.5
      #31 0x00007f8879e50a2f in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
      #32 0x00007f8879e525e9 in ?? () from /usr/lib/libglib-2.0.so.0
      #33 0x00007f8879e5262e in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
      #34 0x00007f887cd247fe in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #35 0x00007f887cc90eb3 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #36 0x00007f887cc911ed in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #37 0x00007f887ca4124f in QThread::exec() () from /usr/lib/libQt5Core.so.5
      #38 0x00007f887d7039d7 in QQmlThreadPrivate::run (this=0x7f8868005150) at qtdeclarative-everywhere-src-5.12.0/src/qml/qml/ftw/qqmlthread.cpp:148
      #39 0x00007f887ca43fc4 in ?? () from /usr/lib/libQt5Core.so.5
      #40 0x00007f887c962a9d in start_thread () from /usr/lib/libpthread.so.0
      #41 0x00007f887c562b23 in clone () from /usr/lib/libc.so.6
      

        Attachments

          Issue Links

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

            Activity

              People

              • Assignee:
                ulherman Ulf Hermann
                Reporter:
                salve Peter Gerd
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: