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

Main thread hangs in QSGThreadedRenderLoop::polishAndSync

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P1: Critical
    • None
    • 5.12.9, 5.12.10, 6.4.2
    • Quick: SceneGraph
    • None
    • Windows 10, x64
    • Windows

    Description

      ****************************************************************************
      **Edit** Some of our users can't start app at all due to this bug.
      I think, this bug affects all the desktop applications using QML under Windows, in case there A-Volute's Sonic Studio is installed on the user's PC.
      This software is installed by e.g. Asus and Dell.
      ****************************************************************************

      One of our users reported this:

      "Another bug which usually occurs is that when I hibernate my system and then resume the FDM will enter the non-responding state. I usually close it via task manager and then restart."

      He sent me the process dump. I've analyzed it and found the culprit, and also the possible reason of the bug.

      First of all, the main thread hangs here: 

      ntdll.dll!NtWaitForSingleObject()	 
      KERNELBASE.dll!WaitForSingleObjectEx()	 
      Qt5Core.dll!QWaitCondition::wait(QMutex * mutex, unsigned long time) Line 178	 
      Qt5Quick.dll!QSGThreadedRenderLoop::polishAndSync(QSGThreadedRenderLoop::Window * w, bool inExpose) Line 1218	 
      Qt5Quick.dll!QSGThreadedRenderLoop::handleExposure(QQuickWindow * window) Line 1012	 
      Qt5Gui.dll!QWindow::event(QEvent * ev) Line 2365	 
      Qt5Widgets.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 3702	 
      Qt5Widgets.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 3529	 
      Qt5Core.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1088	 
      Qt5Gui.dll!QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent * e) Line 3078	 
      Qt5Gui.dll!QWindowSystemInterface::sendWindowSystemEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1163	 
      Qt5Gui.dll!QWindowSystemInterface::flushWindowSystemEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1123	 
      qwindows.dll!00007ff876a1668b()	 
      qwindows.dll!00007ff876a235de()	 
      qwindows.dll!00007ff876a243ab()	 
      user32.dll!UserCallWinProcCheckWow()	 
      user32.dll!DispatchClientMessage()	 
      user32.dll!__fnDWORD()	 
      ntdll.dll!KiUserCallbackDispatcherContinue()	 
      win32u.dll!NtUserDispatchMessage()	 
      user32.dll!DispatchMessageWorker()	 
      Qt5Core.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 640	 
      qwindows.dll!00007ff876a735b9()	 
      Qt5Core.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 225	 
      Qt5Core.dll!QCoreApplication::exec() Line 1389	 
      fdm.exe!main()	 
      fdm.exe!WinMain()	 
      fdm.exe!__scrt_common_main_seh() Line 288	 
      kernel32.dll!BaseThreadInitThunk()	 
      ntdll.dll!RtlUserThreadStart()	 
      

      Here it's seen that QSGThreadedRenderLoop::polishAndSync hangs waiting for a mutex (deadlock). Why? I don't have sources of Qt (did not look into them) and neither I have Windows sources . But... Here is the another thread:  

      win32u.dll!NtUserEnumDisplayMonitors()	 
      d3d9.dll!CEnum::GetAdapterMonitor()	 
      NahimicOSD.dll!00007ff889e4ef5b()	 
      NahimicOSD.dll!00007ff889e4d755()	 
      NahimicOSD.dll!00007ff889e4ad52()	 
      gdi32full.dll!SwapBuffers()	 
      Qt5Gui.dll!QOpenGLContext::swapBuffers(QSurface * surface) Line 1112	 
      Qt5Quick.dll!QSGRenderThread::syncAndRender() Line 653	 
      Qt5Quick.dll!QSGRenderThread::run() Line 733	 
      Qt5Core.dll!QThreadPrivate::start(void * arg) Line 405	 
      kernel32.dll!BaseThreadInitThunk()	 
      ntdll.dll!RtlUserThreadStart()	 
      

      Here I suspect that QSGRenderThread::syncAndRender locked that mutex and then called NtUserEnumDisplayMonitors. And it seems that this NtUserEnumDisplayMonitors hangs too. I think it somehow waits  for Windows UI functions to release their locks (main thread is calling DispatchMessage).

      So, main thread locks Windows's internal UI objects and then attempts to lock some SG Render's object. In the same time another thread already locked that SG Render's object and tries to lock UI object. Classic dead lock.

      Here is another report, but it was closed with "Incomplete" state: https://bugreports.qt.io/browse/QTBUG-42162

       

      Attachments

        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