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

Crash when accessing non-existing QtObject property

    XMLWordPrintable

    Details

    • Commits:
      ea74f0c68cddf706c950d3910cf7b363fe24885b (qt/qtdeclarative/5.12)

      Description

      In Qt 5.13 beta2 and Qt 5.12.3, when accessing a non-existing property of a QtObject e.g. from within a repeater, the application crashes. Up to Qt 5.12.2, this code works and accessing the non-existing property simply returns "undefined" and does not crash.

      When using the same approach with a ListModel (replace the list<QtObject> with the commented ListModel), no crash occurs.

      The use case here are optional properties, with the delegate using a default when the property does not exist.

      Find the relevant code below, complete test case is attached.

      property list<QtObject> entries: [
          QtObject { readonly property color color: "green" },       
          QtObject { }    
      ]
      
      /* ListModel {
          id: entries       
          ListElement { color: "green" }
          ListElement { }
      } */    
      
      Row {
          Repeater {
              model: entries
              Rectangle {
                  width: 50
                  height: 50
                  color: model.color ? model.color : "red"
              }        
          }    
      }
      

      Backtrace:

      Exception Type: EXC_BAD_ACCESS (SIGSEGV)
      Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000004
      Exception Note: EXC_CORPSE_NOTIFY

      Termination Signal: Segmentation fault: 11

      Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
      0 org.qt-project.QtQml 0x0000000101bde434 QV4::QObjectWrapper::getProperty(QV4::ExecutionEngine*, QObject*, QQmlPropertyData*) + 324
      1 org.qt-project.QtQml 0x0000000101be2695 QV4::QObjectWrapper::virtualResolveLookupGetter(QV4::Object const*, QV4::ExecutionEngine*, QV4::Lookup*) + 517
      2 org.qt-project.QtQml 0x0000000101bfb9a7 QV4::Moth::VME::interpret(QV4::CppStackFrame*, QV4::ExecutionEngine*, char const*) + 2087
      3 org.qt-project.QtQml 0x0000000101bfb05b QV4::Moth::VME::exec(QV4::CppStackFrame*, QV4::ExecutionEngine*) + 139
      4 org.qt-project.QtQml 0x0000000101ba35c6 QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*) + 342
      5 org.qt-project.QtQml 0x0000000101d1bf65 QQmlJavaScriptExpression::evaluate(QV4::CallData*, bool*) + 597
      6 org.qt-project.QtQml 0x0000000101d23fc7 QQmlNonbindingBinding::doUpdate(QQmlJavaScriptExpression::DeleteWatcher const&, QFlags<QQmlPropertyData::WriteFlag>, QV4::Scope&) + 295
      7 org.qt-project.QtQml 0x0000000101d220ee QQmlBinding::update(QFlags<QQmlPropertyData::WriteFlag>) + 318
      8 org.qt-project.QtQml 0x0000000101d35396 QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) + 326
      9 org.qt-project.QtQml 0x0000000101cbd02f QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt&) + 207
      10 org.qt-project.QtQml 0x0000000101cbce0f QQmlEnginePrivate::incubate(QQmlIncubator&, QQmlContextData*) + 415
      11 org.qt-project.QtQml 0x0000000101d8f327 QQmlDelegateModelPrivate::object(QQmlListCompositor::Group, int, QQmlIncubator::IncubationMode) + 1799
      12 org.qt-project.QtQuick 0x00000001013c2a9e QQuickRepeater::regenerate() + 270
      13 org.qt-project.QtQuick 0x00000001013c2d82 QQuickRepeater::componentComplete() + 82
      14 org.qt-project.QtQml 0x0000000101d35563 QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) + 787
      15 org.qt-project.QtQml 0x0000000101cb9ff9 QQmlComponentPrivate::complete(QQmlEnginePrivate*, QQmlComponentPrivate::ConstructionState*) + 73
      16 org.qt-project.QtQml 0x0000000101cb7f66 QQmlComponentPrivate::completeCreate() + 102
      17 org.qt-project.QtQml 0x0000000101cb9902 QQmlComponent::create(QQmlContext*) + 114
      18 org.qt-project.QtQml 0x0000000101d26257 QQmlApplicationEnginePrivate::finishLoad(QQmlComponent*) + 87
      19 org.qt-project.QtQml 0x0000000101d268e2 QQmlApplicationEngine::load(QUrl const&) + 34
      20 com.kdab.qtobjectcrash 0x0000000101177b84 main + 260 (main.cpp:17)
      21 libdyld.dylib 0x00007fff57b333d5 start + 1

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              ulherman Ulf Hermann
              Reporter:
              frank.osterfeld Frank Osterfeld
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes