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

Crash in Qt3D at startup due to static opengl context threading issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.7.0 RC
    • 5.7.0 Beta
    • Core: Plugins, Qt3D
    • 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)
      

      Attachments

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

        Activity

          People

            seanharmer Sean Harmer
            anmaatta Antti Määttä
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes