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

QThread initialization is causing data race

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.14.2
    • Core: Threads
    • None
    • macOS

    Description

      Please reference attached "test case.txt" for a simple test case of the `QThread`, and "call stack.txt" to show the call stack of the data race reported in the simple test case. Please enable `tsan` for reproducing it.

       

      `QMetaObject::invokeMethod` is causing data race if the object belongs to another `QThread`, and the `QThread` is being started.

      In the `QThread` implementation for `unix`, there is some initialization work (preparing event dispatcher, etc.) not guarded by mutex, and if the `QThread` is creating event dispatcher, and another thread is calling `wakeUp` because of `postEvent`, 2 threads are accessing the data at the same time.

       

      The stack trace has pointed out the data race is in "qeventdispatcher_unix.cpp:181".

      Attachments

        1. call stack.txt
          4 kB
        2. test case.txt
          0.6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            pengyunquan Peng Yunquan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes