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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.7.0 Beta
    • Fix Version/s: 5.7.0 RC
    • Component/s: Core: Plugins, Qt3D
    • Labels:
      None
    • Environment:
      Qt 5.7.0, Windows 7 64bit, Intel HD Graphics 4600
    • Commits:
      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

            Assignee:
            seanharmer Sean Harmer
            Reporter:
            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