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

Race Condition or Crash in Qt3D due to Thread Affinity of NodePostConstructorInit::processNodes()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.5.4, 6.6.1, 6.7.0 FF
    • 6.5.3, 6.6.0 Beta4, 6.7.0
    • Qt3D
    • None
    • All
    • e275b1c28 (dev), a43c740d4 (6.6), 4eb0953ad (6.5)

    Description

      When creating multiple QNodes, Qt3D may invoke NodePostConstructorInit::processNodes() on either the main thread or the rendering thread.

      If it's called on the main thread, the rendering thread appears to be blocked for synchronization. This seems to be the correct approach because the method calls QPrivateNode::_q_postConstructorInit(), which uses a QNodeVisitor that operates on QNodes living on the main thread.

      The NodePostConstructorInit::addNode(QNode *node) method queues processNodes() to run on the rendering thread. This is because NodePostConstructorInit has rendering thread affinity.

      The crash or race condition occurs when both the main thread and the rendering thread are reading from or writing to the QNode tree structure.

      To resolve this, we have a few options:

      1. Make NodePostConstructorInit have main thread affinity.
      2. Remove the queued processNodes(). This seems like a reasonable solution, as processNodes() is called on every frame.
      3. Post processNodes() to run on the main thread.

      I've attached a backtrace that highlights the issue. While the crash may present with different backtraces, the root cause consistently stems from NodePostConstructorInit::processNodes().

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            seanharmer Sean Harmer
            vpicaver Philip Schuchardt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes