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

Main thread hangs in QSGThreadedRenderLoop::polishAndSync

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P2: Important
    • None
    • 6.4.2
    • Quick: SceneGraph
    • None
    • Windows 10
    • Windows

    Description

      My app was running in background (i.e. main window was hidden). When I switched to it, I've found that it does not respond. I made dump of it and found that the main thread is stuck with the following stack trace:

      ntdll.dll!NtWaitForSingleObject()
      KERNELBASE.dll!WaitForSingleObjectEx()
      [Inline Frame] Qt6Core.dll!QWaitConditionPrivate::wait(QWaitConditionEvent *) Line 75
      Qt6Core.dll!QWaitCondition::wait(QMutex * mutex, unsigned long time) Line 133
      Qt6Core.dll!QWaitCondition::wait(QMutex * mutex, QDeadlineTimer deadline) Line 144
      Qt6Quick.dll!QSGThreadedRenderLoop::polishAndSync(QSGThreadedRenderLoop::Window * w, bool inExpose) Line 1586
      Qt6Quick.dll!QSGThreadedRenderLoop::handleExposure(QQuickWindow * window) Line 1289
      Qt6Gui.dll!QWindow::event(QEvent * ev) Line 2473
      Qt6Widgets.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 3317
      Qt6Widgets.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 3269
      Qt6Core.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1026
      Qt6Gui.dll!QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent * e) Line 3188
      Qt6Gui.dll!QWindowSystemInterface::sendWindowSystemEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1109
      Qt6Gui.dll!QWindowSystemInterface::flushWindowSystemEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1074
      qwindows.dll!00007ff8a1adc800()
      qwindows.dll!00007ff8a1a8b453()
      qwindows.dll!00007ff8a1a8c1d3()
      user32.dll!UserCallWinProcCheckWow()
      user32.dll!DispatchClientMessage()
      user32.dll!__fnDWORD()
      ntdll.dll!KiUserCallbackDispatcherContinue()
      win32u.dll!NtUserDispatchMessage()
      user32.dll!DispatchMessageWorker()
      Qt6Core.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 533
      Qt6Gui.dll!QWindowsGuiEventDispatcher::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 37
      [Inline Frame] Qt6Core.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag>) Line 100
      Qt6Core.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 182
      Qt6Core.dll!QCoreApplication::exec() Line 1347 

      This is similar to QTBUG-86329 except that it seems there is no interference from a third party software.

      It seems the culprit of the deadlock is another thread stuck with the following stack trace:

      ntdll.dll!NtWaitForSingleObject()
      KERNELBASE.dll!WaitForSingleObjectEx()
      [Inline Frame] Qt6Core.dll!QWaitConditionPrivate::wait(QWaitConditionEvent *) Line 75
      Qt6Core.dll!QWaitCondition::wait(QMutex * mutex, unsigned long time) Line 133
      Qt6Core.dll!QWaitCondition::wait(QMutex * mutex, QDeadlineTimer deadline) Line 144
      [Inline Frame] Qt6Quick.dll!QSGRenderThreadEventQueue::takeEvent(bool) Line 204
      [Inline Frame] Qt6Quick.dll!QSGRenderThread::processEventsAndWaitForMore() Line 831
      Qt6Quick.dll!QSGRenderThread::run() Line 952
      Qt6Core.dll!QThreadPrivate::start(void * arg) Line 292
      kernel32.dll!BaseThreadInitThunk()
      ntdll.dll!RtlUserThreadStart() 

      So, it seems (I'm not sure btw, never saw the code) that QSGRenderThreadEventQueue::takeEvent waits for a resource locked by QSGThreadedRenderLoop::polishAndSync (or someone who called it) while QSGThreadedRenderLoop::polishAndSync waits for another one locked by QSGRenderThreadEventQueue::takeEvent.

      Attachments

        1. dump.png
          282 kB
          Joris Vergeer
        2. threads.txt
          22 kB
          Alexander Dyagilev
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            janichol Andy Nichols
            alervd Alexander Dyagilev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes