Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
5.11.2
-
None
-
-
1b9af84c1bb66770f607e157991375f7cb7ae0fb
Description
We're hitting a hang on shutdown of our application when we have an OpenGL view visible when we close our application. From my own debugging it appears to be a race condition. What appears to be happening is that during shutdown the main thread render loop terminates and then the application destructs, which triggers clean-up of the window objects. At the same time, the OpenGL window is invalidated which triggers it attempting to flush events. The events will never get flushed because they are being marshalled to the GUI thread which already terminated. The main thread will never progress because it's stuck waiting for the background render thread to terminate. Deadlock.
Call stack for render thread:
> ntdll.dll!NtWaitForSingleObject() Unknown> ntdll.dll!NtWaitForSingleObject() Unknown KernelBase.dll!WaitForSingleObjectEx() Unknown x.exe!QWaitCondition::wait(class QMutex *,unsigned long) C+ x.exe!QWindowSystemInterface::flushWindowSystemEvents(class QFlags<enum QEventLoop::ProcessEventsFlag>) C x.exe!QWindowSystemInterface::handleGeometryChange<struct QWindowSystemInterface::SynchronousDelivery>(class QWindow *,class QRect const &) C x.exe!QWindowsWindow::initialize(void) C x.exe!QWindowPrivate::create(bool,unsigned __int64) C x.exe!QOffscreenSurface::create(void) C x.exe!QOpenGLVertexArrayObjectPrivate::destroy(void) C x.exe!QMetaObject::activate(class QObject *,int,int,void * *) C x.exe!QOpenGLContext::destroy(void) C x.exe!QOpenGLContext::`vector deleting destructor'(unsigned int) C x.exe!QSGRenderThread::invalidateOpenGL(class QQuickWindow *,bool,class QOffscreenSurface *) C x.exe!QSGRenderThread::event(class QEvent *) C x.exe!QSGRenderThread::processEventsAndWaitForMore(void) C x.exe!QSGRenderThread::run(void) C x.exe!QThreadPrivate::start(void *) C+ kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown
Call stack for main thread:
> ntdll.dll!NtWaitForSingleObject() Unknown> ntdll.dll!NtWaitForSingleObject() Unknown KernelBase.dll!WaitForSingleObjectEx() Unknown x.exe!QWaitCondition::wait(class QMutex *,unsigned long) C+ x.exe!QSGThreadedRenderLoop::releaseResources(struct QSGThreadedRenderLoop::Window *,bool) C x.exe!QSGThreadedRenderLoop::windowDestroyed(class QQuickWindow *) C x.exe!QQuickWindow::~QQuickWindow(void) C x.exe!QQmlPrivate::QQmlElement<class QQuickWindowQmlImpl>::`vector deleting destructor'(unsigned int) C x.exe!QQmlApplicationEngine::~QQmlApplicationEngine(void) C x.exe!main(int argc, char * * argv) Line 200 C [Inline Frame] x.exe!invoke_main() Line 78 C x.exe!__scrt_common_main_seh() Line 288 C+ kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown