Priority: Not Evaluated
Resolution: Out of scope
Affects Version/s: 5.12.10
Fix Version/s: None
Component/s: Core: I/O
I had unexplained crashes, I finally was able to extract the code from my project and reduce it to the code below.
It seems that QFile crashes if binary data is written to a file that ends with the .txt extension even though QIODevice::Text is not specified. Also not on the first file, it seems like changing filenames is needed too.
Granted, typically giving a binary file an extension .txt is not that logical. But I do not expect it to crash due to the filename used, nor other behavior depending on the extension.
I tested against. Qt5.5.1 MinGW, Qt5.12.1 VS2017 32bit, Qt5.12.10 VS2017 32bit and Qt5.12.10 MinGW 64bit. All same behavior. I'm running Windows 10.
I also replaced the QFile write with basic fopen/fwrite/fclose, and then it does not crash.
I also tried the setTextMode(false) on the file with no effect. Also tried to use a DataStream in to write, also crashes.
I was not able to catch it in the debugger by breaking on exception. It crashes without a usable stack trace.
Running the following code once, works.
After the output txt files are created, consecutive runs crash after a few for-loop iterations. It does not trace the "Done", so crashes either in the write or the close or something
It no longer crashes if (see also the commented code below):
-Changing the extension to anything but .txt
-deleting the file at forehand
-Not changing the destination filename each iteration
-Using ASCII values, e.g. instead of append (1) appending 65 ('A')
So to reproduce, run following console app, this goes oke and creates 100 out text files.
Then run it again. Now it crashes still managing to write a handful of out text files though. The amout of files it manages to write before it crashes also varies, why that is I have no clue.