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

Accessing singleton QML type via multiple test cases causes segfault

    XMLWordPrintable

Details

    Description

      Here I have multiple test cases making use of the same QML component which accesses a C++ QML singleton type. The first test case runs fine, the 2nd segfaults when attempting to access the singleton type.

      Thus far I have only seen this issue in the context of unit testing, but it may not be limited to that. Accessing the singleton directly from the test cases rather than from an additional QML component does not trigger the bug. Qt 5.9.2 was not affected.

      See attached project files.

      Reproduce as follows:

      ~/Qt/5.10.1/clang_64/bin/qmake CONFIG+=debug
      make
      ./singletonbug
      

      LLDB backtrace:

      (lldb) target create "./singletonbug"
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtQuickTest.framework/Versions/5/QtQuickTest empty dSYM file detected, dSYM was created with an executable with no debug info.
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtTest.framework/Versions/5/QtTest empty dSYM file detected, dSYM was created with an executable with no debug info.
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtCore.framework/Versions/5/QtCore empty dSYM file detected, dSYM was created with an executable with no debug info.
      warning: 'QtCore' contains a debug script. To run this script in this debug session:
      
          command script import "/Users/forest/Qt/5.10.1/clang_64/lib/QtCore.framework.dSYM/Contents/Resources/DWARF/../Python/QtCore.py"
      
      To run all discovered debug scripts in this session:
      
          settings set target.load-script-from-symbol-file true
      
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets empty dSYM file detected, dSYM was created with an executable with no debug info.
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtGui.framework/Versions/5/QtGui empty dSYM file detected, dSYM was created with an executable with no debug info.
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtQml.framework/Versions/5/QtQml empty dSYM file detected, dSYM was created with an executable with no debug info.
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork empty dSYM file detected, dSYM was created with an executable with no debug info.
      warning: (x86_64) /Users/forest/Qt/5.10.1/clang_64/lib/QtQuick.framework/Versions/5/QtQuick empty dSYM file detected, dSYM was created with an executable with no debug info.
      Current executable set to './singletonbug' (x86_64).
      (lldb) env DYLD_IMAGE_SUFFIX=_debug
      (lldb) run
      Process 22662 launched: './singletonbug' (x86_64)
      ********* Start testing of all *********
      Config: Using QtTest library 5.10.1, Qt 5.10.1 (x86_64-little_endian-lp64 shared (dynamic) debug build; by Clang 8.1.0 (clang-802.0.42) (Apple))
      PASS   : all::A::initTestCase()
      QDEBUG : all::A::test_the_thing() qml: *** DOING THE THING ***
      QDEBUG : all::A::test_the_thing() qml: MySingleton MySingleton(0x102fa5260)
      PASS   : all::A::test_the_thing()
      PASS   : all::A::cleanupTestCase()
      PASS   : all::B::initTestCase()
      QDEBUG : all::B::test_the_thing() qml: *** DOING THE THING ***
      Process 22662 stopped
      * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
          frame #0: 0x0000000101bcd695 QtQml_debug`QQmlData::get(object=0x0000000102fa5260, create=true) at qqmldata_p.h:243
      Target 0: (singletonbug) stopped.
      (lldb) bt
      * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
        * frame #0: 0x0000000101bcd695 QtQml_debug`QQmlData::get(object=0x0000000102fa5260, create=true) at qqmldata_p.h:243
          frame #1: 0x0000000101ee5a96 QtQml_debug`QQmlData::ensurePropertyCache(engine=0x00007fff5fbfecf8, object=0x0000000102fa5260) at qqmldata_p.h:275
          frame #2: 0x0000000101f62046 QtQml_debug`QQmlType::SingletonInstanceInfo::init(this=0x0000000102e00800, e=0x00007fff5fbfecf8) at qqmlmetatype.cpp:274
          frame #3: 0x000000010201288b QtQml_debug`QV4::QQmlTypeWrapper::get(m=0x000000010c36f7e0, name=0x000000010c36f2f8, hasProperty=0x0000000000000000) at qqmltypewrapper.cpp:188
          frame #4: 0x0000000101cf7f01 QtQml_debug`QV4::Object::get(this=0x000000010c36f7e0, name=0x000000010c36f2f8, hasProperty=0x0000000000000000) const at qv4object_p.h:380
          frame #5: 0x0000000101f14e19 QtQml_debug`QV4::RuntimeHelpers::objectDefaultValue(object=0x000000010c36f7e0, typeHint=1) at qv4runtime.cpp:431
          frame #6: 0x0000000101cf8ef5 QtQml_debug`QV4::RuntimeHelpers::toPrimitive(value=0x000000010c36f7e0, typeHint=0) at qv4runtime_p.h:126
          frame #7: 0x0000000101f15788 QtQml_debug`QV4::convert_to_string_add(engine=0x00000001030a0200, value=0x000000010c36f7e0) at qv4runtime.cpp:525
          frame #8: 0x0000000101f11efc QtQml_debug`QV4::Runtime::method_addString(engine=0x00000001030a0200, left=0x000000010c36f780, right=0x000000010c36f778) at qv4runtime.cpp:581
          frame #9: 0x0000000103f4556e
          frame #10: 0x0000000101dbe3d3 QtQml_debug`QV4::ExecutionContext::simpleCall(this=0x000000010c36f750, scope=0x00007fff5fbfb668, callData=0x000000010c36f6e8, function=0x0000000102e86680) at qv4context.cpp:302
          frame #11: 0x0000000101df0fd5 QtQml_debug`QV4::ScriptFunction::call(that=0x000000010c36f740, scope=0x00007fff5fbfb668, callData=0x000000010c36f6e8) at qv4functionobject.cpp:409
          frame #12: 0x0000000101cf6a21 QtQml_debug`QV4::Object::call(this=0x000000010c36f740, scope=0x00007fff5fbfb668, d=0x000000010c36f6e8) const at qv4object_p.h:445
          frame #13: 0x0000000101f0f4f6 QtQml_debug`QV4::Runtime::method_callProperty(engine=0x00000001030a0200, nameIndex=8, callData=0x000000010c36f6e8) at qv4runtime.cpp:1104
          frame #14: 0x0000000103f4450e
          frame #15: 0x0000000101dbe3d3 QtQml_debug`QV4::ExecutionContext::simpleCall(this=0x000000010c36f6b8, scope=0x00007fff5fbfb8c8, callData=0x000000010c36f650, function=0x0000000102e2a7e0) at qv4context.cpp:302
          frame #16: 0x0000000101df0fd5 QtQml_debug`QV4::ScriptFunction::call(that=0x000000010c36f6a8, scope=0x00007fff5fbfb8c8, callData=0x000000010c36f650) at qv4functionobject.cpp:409
          frame #17: 0x0000000101cf6a21 QtQml_debug`QV4::Object::call(this=0x000000010c36f6a8, scope=0x00007fff5fbfb8c8, d=0x000000010c36f650) const at qv4object_p.h:445
          frame #18: 0x0000000101f0f7e3 QtQml_debug`QV4::Runtime::method_callElement(engine=0x00000001030a0200, index=0x000000010c0ec610, callData=0x000000010c36f650) at qv4runtime.cpp:1141
          frame #19: 0x0000000109726457
          frame #20: 0x0000000101dbdf46 QtQml_debug`QV4::ExecutionContext::call(this=0x000000010c36f5c0, scope=0x00007fff5fbfbbc8, callData=0x000000010c36f558, function=0x0000000102f731f0, f=0x000000010c36f5b8) at qv4context.cpp:274
          frame #21: 0x0000000101df1020 QtQml_debug`QV4::ScriptFunction::call(that=0x000000010c36f5b0, scope=0x00007fff5fbfbbc8, callData=0x000000010c36f558) at qv4functionobject.cpp:411
          frame #22: 0x0000000101cf6a21 QtQml_debug`QV4::Object::call(this=0x000000010c36f5b0, scope=0x00007fff5fbfbbc8, d=0x000000010c36f558) const at qv4object_p.h:445
          frame #23: 0x0000000101f0ef99 QtQml_debug`QV4::Runtime::method_callActivationProperty(engine=0x00000001030a0200, nameIndex=111, callData=0x000000010c36f558) at qv4runtime.cpp:1052
          frame #24: 0x0000000109726bbc
          frame #25: 0x0000000101dbe3d3 QtQml_debug`QV4::ExecutionContext::simpleCall(this=0x000000010c36f510, scope=0x00007fff5fbfbec8, callData=0x000000010c36f4a8, function=0x0000000102f73400) at qv4context.cpp:302
          frame #26: 0x0000000101df0fd5 QtQml_debug`QV4::ScriptFunction::call(that=0x000000010c36f500, scope=0x00007fff5fbfbec8, callData=0x000000010c36f4a8) at qv4functionobject.cpp:409
          frame #27: 0x0000000101cf6a21 QtQml_debug`QV4::Object::call(this=0x000000010c36f500, scope=0x00007fff5fbfbec8, d=0x000000010c36f4a8) const at qv4object_p.h:445
          frame #28: 0x0000000101f0ef99 QtQml_debug`QV4::Runtime::method_callActivationProperty(engine=0x00000001030a0200, nameIndex=113, callData=0x000000010c36f4a8) at qv4runtime.cpp:1052
          frame #29: 0x000000010972ae6f
          frame #30: 0x0000000101dbdf46 QtQml_debug`QV4::ExecutionContext::call(this=0x000000010c36f410, scope=0x00007fff5fbfc1c8, callData=0x000000010c36f3a8, function=0x0000000102f73460, f=0x000000010c36f408) at qv4context.cpp:274
          frame #31: 0x0000000101df1020 QtQml_debug`QV4::ScriptFunction::call(that=0x000000010c36f400, scope=0x00007fff5fbfc1c8, callData=0x000000010c36f3a8) at qv4functionobject.cpp:411
          frame #32: 0x0000000101cf6a21 QtQml_debug`QV4::Object::call(this=0x000000010c36f400, scope=0x00007fff5fbfc1c8, d=0x000000010c36f3a8) const at qv4object_p.h:445
          frame #33: 0x0000000101f0ef99 QtQml_debug`QV4::Runtime::method_callActivationProperty(engine=0x00000001030a0200, nameIndex=115, callData=0x000000010c36f3a8) at qv4runtime.cpp:1052
          frame #34: 0x000000010972c1f1
          frame #35: 0x0000000101dbe3d3 QtQml_debug`QV4::ExecutionContext::simpleCall(this=0x0000000103f98088, scope=0x00007fff5fbfc5b0, callData=0x000000010c36f328, function=0x0000000102f73c20) at qv4context.cpp:302
          frame #36: 0x0000000101ff9df2 QtQml_debug`QQmlJavaScriptExpression::evaluate(this=0x0000000102e86870, callData=0x000000010c36f328, isUndefined=0x0000000000000000, scope=0x00007fff5fbfc5b0) at qqmljavascriptexpression.cpp:223
          frame #37: 0x0000000101f5ec4f QtQml_debug`QQmlBoundSignalExpression::evaluate(this=0x0000000102e86870, a=0x0000000000000000) at qqmlboundsignal.cpp:223
          frame #38: 0x0000000101f5f3de QtQml_debug`QQmlBoundSignal_callback(e=0x0000000102e864d0, a=0x0000000000000000) at qqmlboundsignal.cpp:355
          frame #39: 0x0000000101fd1e5d QtQml_debug`QQmlNotifier::emitNotify(endpoint=0x0000000000000000, a=0x0000000000000000) at qqmlnotifier.cpp:106
          frame #40: 0x0000000101f2ff23 QtQml_debug`QQmlData::signalEmitted((null)=0x0000000102e867c0, object=0x0000000102ec2920, index=3, a=0x0000000000000000) at qqmlengine.cpp:856
          frame #41: 0x00000001004ce8be QtCore_debug`QMetaObject::activate(sender=0x0000000102ec2920, signalOffset=3, local_signal_index=0, argv=0x0000000000000000) at qobject.cpp:3644
          frame #42: 0x00000001004ce7fd QtCore_debug`QMetaObject::activate(sender=0x0000000102ec2920, m=0x00000001020f8aa0, local_signal_index=0, argv=0x0000000000000000) at qobject.cpp:3629
          frame #43: 0x0000000102096b82 QtQml_debug`QQmlComponentAttached::completed(this=0x0000000102ec2920) at moc_qqmlcomponentattached_p.cpp:138
          frame #44: 0x000000010201f2e8 QtQml_debug`QQmlObjectCreator::finalize(this=0x0000000102ea78f0, interrupt=0x00007fff5fbfe588) at qqmlobjectcreator.cpp:1339
          frame #45: 0x0000000101f5196c QtQml_debug`QQmlComponentPrivate::complete(enginePriv=0x0000000102e2a270, state=0x0000000102e29d40) at qqmlcomponent.cpp:920
          frame #46: 0x0000000101f4f95b QtQml_debug`QQmlComponentPrivate::completeCreate(this=0x0000000102e29ca0) at qqmlcomponent.cpp:956
          frame #47: 0x0000000101f51a32 QtQml_debug`QQmlComponent::completeCreate(this=0x0000000102eab840) at qqmlcomponent.cpp:949
          frame #48: 0x0000000101f50e46 QtQml_debug`QQmlComponent::create(this=0x0000000102eab840, context=0x0000000102f97ca0) at qqmlcomponent.cpp:775
          frame #49: 0x0000000102900789 QtQuick_debug`QQuickView::continueExecute(this=0x00007fff5fbfebb8) at qquickview.cpp:471
          frame #50: 0x00000001029004a4 QtQuick_debug`QQuickViewPrivate::execute(this=0x0000000102eab530) at qquickview.cpp:107
          frame #51: 0x0000000102900bf0 QtQuick_debug`QQuickView::setSource(this=0x00007fff5fbfebb8, url=0x00007fff5fbfeaf0) at qquickview.cpp:236
          frame #52: 0x00000001000a20c0 QtQuickTest_debug`quick_test_main(argc=1, argv=0x00007fff5fbfefc8, name="all", sourceDir=".") at quicktest.cpp:515
          frame #53: 0x0000000100004ff5 singletonbug`main(argc=1, argv=0x00007fff5fbfefc8) at singletonbug.cpp:11
          frame #54: 0x00007fffa99f7235 libdyld.dylib`start + 1
          frame #55: 0x00007fffa99f7235 libdyld.dylib`start + 1
      

      Attachments

        1. MySingleton.h
          0.3 kB
        2. singletonbug.cpp
          0.3 kB
        3. singletonbug.pro
          0.1 kB
        4. Thing.qml
          0.2 kB
        5. tst_A.qml
          0.1 kB
        6. tst_B.qml
          0.1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shausman Simon Hausmann
            forest Forest Bond
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes