Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
5.6.3
-
None
-
macOS 10.13.6
4.2 GHz Intel Core i7 (4 core) iMac
-
-
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.