Details
Description
Problem: In some cases, the contents of the output of the "qtdiag" command generated by building Qt is incomplete.
Steps to reproduce: Open command prompt, run "qtdiag > output.txt" and verify that the contents of "output.txt" differ from the contents that are written on the console when the command "qtdiag" is run by itself.
It happens only on a few Windows machines, but on those machines it happens very frequently/always. See below for a longer explanation.
We've identified an issue in some machines where the output of the "qtdiag" is "incomplete". It doesn't happen in all machines but it happens often/all the time in the machines that are affected.
On those machines, running the command "qtdiag" in a Windows command prompt outputs everything as expected. However, piping the output to a file via, for example, "qtdiag > output.txt" will often result in the output.txt file having only a part of the expected contents. This behavior is also noticed on those machines when calling "qtdiag" programmatically and piping its output - in our specific case, via Python's "subprocess.check_output('qtdiag')".
We've investigated the issue a bit and noticed that "qtdiag" doesn't explicitly flush its string contents on the source code (seen here at http://code.qt.io/cgit/qt/qttools.git/tree/src/qtdiag/main.cpp). We've created a local version of "qtdiag" that adds a "std::wcout.flush();" line after the text stream write and we confirm that solves the issue, so the current hypothesis is that the stream is not being flushed completely before the process ends, but only on some machines, and only on Windows.
Attachments
For Gerrit Dashboard: QTBUG-67860 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
230217,2 | Flush wcout before exiting the app | 5.11 | qt/qttools | Status: MERGED | +2 | 0 |