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

QTemporaryFile race on macOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.10.0
    • 5.6.3
    • None
    • macOS 10.13.6
      4.2 GHz Intel Core i7 (4 core) iMac
    • macOS
    • 19b0ce5daa31e2ffebfcf2701143742302f1deb4

    Description

      According to the documentation QTemporaryFile's functions are reentrant. So I would expect to be able to call QTemporaryFile::open concurrently from different threads as long as each thread is using its own separate QTemporaryFile object.

      However, I've observed what appears to be a race where different threads with different QTemporaryFile objects can incorrectly generate identical file paths.

      Please see the attached test program to reproduce.

      The test program has a conditional compilation option to compare QTemporaryFile with the mkstemp API. The mkstemp version generates the expected number of unique temporary file paths but the QTemporaryFile version does not.

      If the QTemporaryFile-built version succeeds then try running the program several times in a row, and/or increase the testCount value to something higher. On my iMac it fails on every run but if it is a race then it may vary at runtime depending on the system.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            hendoauscba Neil Henderson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes