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

Crash when destroying QQmlPropertyMap

XMLWordPrintable

    • All

      Calling the destroy() method of QQmlPropertyMap in QML environment cause the program to crash.

      Here's a minimal reproducible example:
      main.cpp

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      #include <QQmlContext>
      #include <QQmlPropertyMap>
      
      class Utils : public QObject {
          Q_OBJECT
      public:
          explicit Utils(QObject *parent = nullptr) : QObject(parent) { }
      
      public slots:
          QQmlPropertyMap *createObject(QObject *parent = nullptr)
          {
              return new QQmlPropertyMap(parent);
          }
      };
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
      
          Utils utils;
          QQmlApplicationEngine engine;
          engine.rootContext()->setContextProperty("Utils", &utils);
      
          const QUrl url(QStringLiteral("qrc:/main.qml"));
          QObject::connect(
              &engine,
              &QQmlApplicationEngine::objectCreated,
              &app,
              [url](QObject *obj, const QUrl &objUrl) {
                  if (!obj && url == objUrl)
                      QCoreApplication::exit(-1);
              },
              Qt::QueuedConnection);
          engine.load(url);
      
          return app.exec();
      }
      
      #include "main.moc"
      

      main.qml

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      
      Window {
          id: window
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Button {
              anchors.centerIn: parent
              text: "Crash Me"
              onClicked: {
                  const person = Utils.createObject(window);
                  person.groan = "114514";
                  console.log(person.groan);
                  person.destroy();
              }
          }
      }
      

      call stack

      >   Qt6Qml.dll!QV4::setupQObjectMethodLookup<QV4::Heap::QObjectMethod>(QV4::Lookup * lookup, const QQmlData * ddata, const QQmlPropertyData * propertyData, const QV4::Object * self, QV4::Heap::QObjectMethod * method) Line 484   C++
          Qt6Qml.dll!QV4::QObjectWrapper::virtualResolveLookupGetter(const QV4::Object * object, QV4::ExecutionEngine * engine, QV4::Lookup * lookup) Line 1125   C++
          Qt6Qml.dll!QV4::Moth::VME::interpret(QV4::JSTypesStackFrame * frame, QV4::ExecutionEngine * engine, const char * code) Line 802 C++
          Qt6Qml.dll!QV4::Moth::VME::exec(QV4::JSTypesStackFrame * frame, QV4::ExecutionEngine * engine) Line 492 C++
          [Inline Frame] Qt6Qml.dll!QV4::doCall(QV4::Function *) Line 52  C++
          Qt6Qml.dll!QV4::Function::call(const QV4::Value * thisObject, const QV4::Value * argv, int argc, QV4::ExecutionContext * context) Line 77   C++
          [Inline Frame] Qt6Qml.dll!QV4::Function::call::__l5::<lambda_1>::operator()(const QV4::Value *) Line 28 C++
          Qt6Qml.dll!QV4::convertAndCall<`QV4::Function::call'::`5'::<lambda_1>>(QV4::ExecutionEngine * engine, QObject * thisObject, void * * a, const QMetaType * types, int argc, QV4::Function::call::__l5::<lambda_1> call) Line 199 C++
          Qt6Qml.dll!QV4::Function::call(QObject * thisObject, void * * a, const QMetaType * types, int argc, QV4::ExecutionContext * context) Line 25    C++
          Qt6Qml.dll!QQmlJavaScriptExpression::evaluate(void * * a, const QMetaType * types, int argc) Line 274   C++
          Qt6Qml.dll!QQmlBoundSignalExpression::evaluate(void * * a) Line 197 C++
          Qt6Qml.dll!QQmlBoundSignal_callback(QQmlNotifierEndpoint * e, void * * a) Line 316  C++
          Qt6Qml.dll!QQmlNotifier::emitNotify(QQmlNotifierEndpoint * endpoint, void * * a) Line 75    C++
          Qt6Core.dll!doActivate<0>(QObject * sender, int signal_index, void * * argv) Line 4151  C++
          Qt6Core.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 4316 C++
          Qt6QuickTemplates2.dll!QQuickAbstractButtonPrivate::trigger(bool doubleClick) Line 393  C++
          Qt6QuickTemplates2.dll!QQuickAbstractButtonPrivate::handleRelease(const QPointF & point, unsigned long timestamp) Line 194  C++
          Qt6QuickTemplates2.dll!QQuickControl::mouseReleaseEvent(QMouseEvent * event) Line 2067  C++
          Qt6Quick.dll!QQuickItemPrivate::deliverPointerEvent(QEvent * event) Line 5692   C++
          Qt6Quick.dll!QQuickItem::event(QEvent * ev) Line 9240   C++
          [Inline Frame] Qt6Core.dll!QCoreApplicationPrivate::notify_helper(QObject *) Line 1281  C++
          [Inline Frame] Qt6Core.dll!doNotify(QObject *) Line 1210    C++
          Qt6Core.dll!QCoreApplication::notify(QObject * receiver, QEvent * event) Line 1194  C++
          Qt6Core.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1109 C++
          Qt6Quick.dll!QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem(QQuickItem * item, bool isGrabber, QPointerEvent * pointerEvent, bool handlersOnly) Line 2476  C++
          Qt6Quick.dll!QQuickDeliveryAgentPrivate::deliverUpdatedPoints(QPointerEvent * event) Line 2230  C++
          Qt6Quick.dll!QQuickDeliveryAgentPrivate::deliverPointerEvent(QPointerEvent * event) Line 2067   C++
          Qt6Quick.dll!QQuickDeliveryAgentPrivate::handleMouseEvent(QMouseEvent * event) Line 1781    C++
          Qt6Quick.dll!QQuickDeliveryAgent::event(QEvent * ev) Line 947   C++
          Qt6Quick.dll!QQuickWindow::event(QEvent * event) Line 1559  C++
          [Inline Frame] Qt6Core.dll!QCoreApplicationPrivate::notify_helper(QObject *) Line 1281  C++
          [Inline Frame] Qt6Core.dll!doNotify(QObject *) Line 1210    C++
          Qt6Core.dll!QCoreApplication::notify(QObject * receiver, QEvent * event) Line 1194  C++
          Qt6Core.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1109 C++
          Qt6Gui.dll!QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent * e) Line 2474   C++
          Qt6Gui.dll!QWindowSystemInterface::sendWindowSystemEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1123   C++
          Qt6Core.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 485 C++
          Qt6Gui.dll!QWindowsGuiEventDispatcher::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 37  C++
          [Inline Frame] Qt6Core.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag>) Line 104   C++
          Qt6Core.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 185 C++
          Qt6Core.dll!QCoreApplication::exec() Line 1452  C++
          no_property_cache_crash.exe!00007ff7083319ff()  Unknown
          no_property_cache_crash.exe!00007ff708331100()  Unknown
          no_property_cache_crash.exe!00007ff70833350a()  Unknown
          kernel32.dll!BaseThreadInitThunk()  Unknown
          ntdll.dll!RtlUserThreadStart()  Unknown
      

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

            qtqmlteam Qt Qml Team User
            gpbeta Joshua GPBeta
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes