Dear all,

I have a program which reads concurrently multiple files using the C I/O
library. I have encountered  a problem, _ftelli64 randomly reports an
incorrect position, with a mismatch of a few bytes. The bug disappears if
any of these changes is done:

   - ftell is used instead of _ftelli64 (but no more large file support)
   - std::ifstream is used instead of C functions (but I need _wfopen for
   unicode file names)
   - files are not read concurrently (reading threads set to 1)

I have reproduced this in the attached MCVE. It does create 8 files
approximately 3MB large, and reads them concurrently in 8 threads by 65544
byte blocks. It compares the value returned by fread() and the difference
between _ftelli64 calls before and after fread(). It prints the mismatches.

Typical output is :

Error 2.dat / ftell before 3080570 / fread returned 65544 / ftell after
3146112 / mismatch -2

Error 6.dat / ftell before 3080569 / fread returned 65544 / ftell after
3146112 / mismatch -1

Error 4.dat / ftell before 65544 / fread returned 65544 / ftell after
131089 / mismatch 1

Error 5.dat / ftell before 0 / fread returned 65544 / ftell after 65543 /
mismatch -1

Error 5.dat / ftell before 65543 / fread returned 65544 / ftell after
131088 / mismatch 1

Error 4.dat / ftell before 2162953 / fread returned 65544 / ftell after
2228498 / mismatch 1

Error 5.dat / ftell before 2162952 / fread returned 65544 / ftell after
2228497 / mismatch 1

Error 4.dat / ftell before 3080570 / fread returned 65544 / ftell after
3146112 / mismatch -2

Error 5.dat / ftell before 3080569 / fread returned 65544 / ftell after
3146112 / mismatch -1


Is this a bug from windows or from MinGW C library?

Thanks!
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to