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

Crash in Qt.createComponent, Qt.createQmlObject

    XMLWordPrintable

Details

    Description

      Calling functions Qt.createComponent or Qt.createQmlObject leads to a crash (assert triggers in debug) when the call is made from an anonymous function created inside an object that was destroyed.

      The reason is that inside builtin method method_createComponent or method_createQmlObject there is assumption that calling QML context is exists, which is not always true. Actually in the described use case the context is absent, and corresponding pointer is null:
       

      // from qqmlbuiltinfunctions.cpp:
      
      QQmlContextData *context = scope.engine->callingQmlContext();
      Q_ASSERT(context);   // <<== this line triggers assert

      See attached test case: click on the green rectangle, and the application will crash in 1 second.

      Inside Qt Declarative submodule there are places where the context pointer is checked for null, for example see qv4runtime.cpp, qv4include.cpp

      Also beside the described case there are places where the context is used without such checks, it should be investigated if those classes could be compromised too, see qqmlxmlhttprequest.cpp, qquickloader.cpp

       

      Attachments

        Issue Links

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

          Activity

            People

              laknoll Lars Knoll
              ailin Aleksei Ilin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes