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

Crash in RHI when exiting a QtWaylandCompositor with active clients.

    XMLWordPrintable

Details

    • Linux/Wayland
    • d68bd21b9d144fcc4552209591d353d791f498ac (qt/qtwayland/dev) 27979837f0770b8c4efa65d227d807516084b508 (qt/qtwayland/6.2)

    Description

      After porting from Qt 5.15 to 6.2 we have a recurring crash in the QtApplicationManager (AM), which is a Wayland compositor based on QtWaylandCompositor.

      This is a timing issue: mostly when exiting the AM while Wayland clients are still running, but also when closing clients and immediately quitting the AM process.

      Please note: this is not reproducible with the example compositors in the qtwayland module. The difference is that the AM actively shuts down the clients via IPC and/or SIGQUIT, before exiting itself.

      What happens is that we are leaking one Texture resource for each Wayland window on RHI shutdown on the main thread. Later the deleteLater() handlers for the matching QSGPlainTextures in the QWaylandQuickItems are executed on the render thread, but this leads to a crash due to RHI being gone already (see backtrace below).

      If I change the QWaylandSurfaceTextureProvider destructor in qwaylandquickitem.cpp to delete immediately instead of calling deleteLater, everything works fine: no crashes, no other weird behavior.

      Apart from that, I think we still shouldn't crash the render thread if RHI is already shutdown, but simply do nothing or print an error message.

       

      [WARN | default] QRhi 0x7fcba4004870 going down with 3 unreleased resources that own native graphics objects. This is not nice.            [qrhi.cpp:4449]
      [WARN | default]   Texture resource 0x7fcba47bc4b0 ()                                                                                      [qrhi.cpp:4452]
      [WARN | default]   Texture resource 0x7fcba47d05a0 ()                                                                                      [qrhi.cpp:4452]
      [WARN | default]   Texture resource 0x7fcba47dd5f0 ()                                                                                      [qrhi.cpp:4452]
      
      *** process appman (36143) crashed ***
      
       > why: uncaught signal 11 (Segmentation fault)
      
       > where: QSGRenderThread thread, TID: 36162, pthread ID: 7fcbce633700
      
       > C++ backtrace:
         0: _FUN [564c4d66bbcb] in /home/sandman/git/qtapplicationmanager/src/common-lib/unixsignalhandler.cpp:156
         1: ? [7fcbfa06813f]
         2: QRhiGles2::DeferredReleaseEntry& QList<QRhiGles2::DeferredReleaseEntry>::emplaceBack<QRhiGles2::DeferredReleaseEntry const&>(QRhiGles2::DeferredReleaseEntry const&) [7fcbfbca179b] in /home/sandman/git/qt-6/qtbase/src/corelib/tools/qlist.h:817
         3: QList<QRhiGles2::DeferredReleaseEntry>::append(QRhiGles2::DeferredReleaseEntry const&) [7fcbfbc9e340] in /home/sandman/git/qt-6/qtbase/src/corelib/tools/qlist.h:396
         4: QGles2Texture::destroy() [7fcbfbc9412c] in /home/sandman/git/qt-6/qtbase/src/gui/rhi/qrhigles2.cpp:4525
         5: QGles2Texture::~QGles2Texture() [7fcbfbc94077] in /home/sandman/git/qt-6/qtbase/src/gui/rhi/qrhigles2.cpp:4506
         6: QGles2Texture::~QGles2Texture() [7fcbfbc9409f] in /home/sandman/git/qt-6/qtbase/src/gui/rhi/qrhigles2.cpp:4507
         7: QSGPlainTexture::~QSGPlainTexture() [7fcbfc694189] in /home/sandman/git/qt-6/qtdeclarative/src/quick/scenegraph/util/qsgplaintexture.cpp:80
         8: QSGPlainTexture::~QSGPlainTexture() [7fcbfc6941c1] in /home/sandman/git/qt-6/qtdeclarative/src/quick/scenegraph/util/qsgplaintexture.cpp:81
         9: qDeleteInEventHandler(QObject*) [7fcbfa28c840] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qobject.cpp:4715
        10: QObject::event(QEvent*) [7fcbfa283d6e] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qobject.cpp:1319
        11: QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) [7fcbfa2102b9] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qcoreapplication.cpp:1222
        12: doNotify [7fcbfa20fedd] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qcoreapplication.cpp:1151
        13: QCoreApplication::notify(QObject*, QEvent*) [7fcbfa20fe4f] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qcoreapplication.cpp:1137
        14: QGuiApplication::notify(QObject*, QEvent*) [7fcbfb873644] in /home/sandman/git/qt-6/qtbase/src/gui/kernel/qguiapplication.cpp:1942
        15: QCoreApplication::notifyInternal2(QObject*, QEvent*) [7fcbfa20fd99] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qcoreapplication.cpp:1061
        16: QCoreApplication::sendEvent(QObject*, QEvent*) [7fcbfa210745] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qcoreapplication.cpp:1469
        17: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) [7fcbfa211467] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qcoreapplication.cpp:1828
        18: QCoreApplication::sendPostedEvents(QObject*, int) [7fcbfa210dbf] in /home/sandman/git/qt-6/qtbase/src/corelib/kernel/qcoreapplication.cpp:1687
        19: QThreadPrivate::finish(void*) [7fcbfa4535ee] in /home/sandman/git/qt-6/qtbase/src/corelib/thread/qthread_unix.cpp:370
        20: __pthread_cleanup_class::~__pthread_cleanup_class() [7fcbfa4543a2] in /usr/include/pthread.h:537
        21: QThreadPrivate::start(void*) [7fcbfa4534cd] in /home/sandman/git/qt-6/qtbase/src/corelib/thread/qthread_unix.cpp:286
        22: start_thread [7fcbfa05cea6] in ./nptl/pthread_create.c:477
        23: __clone [7fcbf9cb3dee]
        24: ? [ffffffffffffffff]
      

      Attachments

        For Gerrit Dashboard: QTBUG-95394
        # Subject Branch Project Status CR V

        Activity

          People

            lagocs Laszlo Agocs
            rgriebl Robert Griebl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews