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

QML EXC_BAD_ACCESS crash

    XMLWordPrintable

Details

    • macOS
    • eb79815fb (dev), 8228f07a2 (6.7), 1586ea1f1 (6.6), 724971240 (tqtc/lts-6.5), dcc6b25cd (tqtc/lts-6.2)

    Description

      I have encountered a strange, and 100% reproducible bug, in QML.

      The project is compiled in Qt Creator in Debug mode. When the project is Run, it always crashes at the same point, following a specific UI action. I have attached a redacted crash log.

      When the project is started in the debugger, there is a particular breakpoint that gets hit multiple times before it allows the following line to be evaluated, which is truly strange. In debug mode, it doesn't crash. I have attached a video snippet of the debug session showing this fault.

      I'm not clear what is causing it but I hazard a guess that there may be a timing issue or conflict in the engine around:

      • a QML component being created: `OoSignInLayer`
      • an external signal being connected to a function in the component
      • that signal being emitted

      Here are the relevant code snippets...
      main.qml

      import QtQuick
      import ...
      
      Window { id: root
         ...
         QtObject { id: sessionManager
            ...
            signal ooSignInNotification(int notificationType, string errorCode)
            ...
            function handleSigningOut()
            {
               modalLayer.showModal(C.ModalLayer.OoSignIn)
               ooSignInNotification(C.NotificationType.Info, qsTr("You have been signed out."))
            }
            ...
         }
         ...
         Item { id: modalLayer
            property int activeModalLayer: C.ModalLayer.None
            ...
            Loader { id: modalLoader
               ...
               sourceComponent:
               {
                  switch (modalLayer.activeModalLayer)
                  {
                  ...
                  case C.ModalLayer.OoSignIn:
                     return ooSignInModalLayerComponent
                  ...
                  }
               }
            }
            ...
            Component { id: ooSignInModalLayerComponent
               FocusScope {
                  focus: true
                  ...
                  OoSignInLayer { id: ooSignInLayer
                     ...
                     Component.onCompleted:
                        sessionManager.ooSignOutNotification.connect(showNotification)
                     ...
                  }
               }
            }
            ...
            function showModal(newModalLayer)
            {
               activeModalLayer = newModalLayer
               visible = true
            }
         }
         ...
      }
      

      OoSignInLayer.qml

      import QtQuick
      
      FocusScope { id: root
         ...
         QtObject { id: my
            property int notificationType: C.NotificationType.None
            ...
         }
         ...
         function showNotification(type: int, message: string)
         {
            my.notificationType = type // The debugger gets stuck here
            notificationMessage.text = message
            usernameField.forceActiveFocus()
         }
         ...
      }
      

      On clicking a particular button in the UI, some actions are taken and sessionManager.handleSigningOut() gets called. This does 3 things:
      1. Calls modalLayer.showModal(C.ModalLayer.OoSignIn) which causes modalLoader to load ooSignInModalLayerComponent and make it visible, which causes an instance of OoSignInLayer to be created.
      2. In main.qml within the instance of OoSignInLayer, Component.onCompleted connects the signal sessionManager.ooSignOutNotification to OoSignInLayer.showNotification().
      3. Back in sessionManager.handleSigningOut(), the signal sessionManager.ooSignOutNotification() is called/emitted.

      Attachments

        1. QML crash.log
          114 kB
        2. QML debug strangeness.mp4
          781 kB
        3. QtLog_QML_Crash.log
          105 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ulherman Ulf Hermann
            paulmasri Paul
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: