Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.7.0 Beta
-
None
-
Qt 5.7.0, Windows 7 64bit, Intel HD Graphics 4600
-
ed7845098f59e5d4df7af681bc15777c0e4ca1d3
Description
There is a race condition between multple threads in the creation of the static opengl context, which results in a crash.
QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext() { qDebug () << "staticOpenGLContext: current thread: " << QThread::currentThread(); QWindowsIntegration *integration = QWindowsIntegration::instance(); if (!integration) return 0; QWindowsIntegrationPrivate *d = integration->d.data(); if (d->m_staticOpenGLContext.isNull()) d->m_staticOpenGLContext = QSharedPointer<QWindowsStaticOpenGLContext>(QWindowsStaticOpenGLContext::create()); return d->m_staticOpenGLContext.data(); }
If two threads get into the line of creation at the same time, the first thread getting out of the function will have the static context deallocated by the second thread, and causing a crash later on.
Multiple threads might be calling the function when at the startup of Qt3D application as seen in the traces:
staticOpenGLContext: current thread: Qt3DRender::Render::RenderThread(0x640218) staticOpenGLContext: current thread: QThread(0x618630) staticOpenGLContext: current thread: Qt3DRender::Render::RenderThread(0x640218) staticOpenGLContext: current thread: QThread(0x618630) staticOpenGLContext: current thread: Qt3DCore::QAspectThread(0x62b4f0) staticOpenGLContext: current thread: Qt3DCore::QAspectThread(0x62b4f0) staticOpenGLContext: current thread: Qt3DCore::QAspectThread(0x62b4f0) staticOpenGLContext: current thread: Qt3DCore::QAspectThread(0x62b4f0)