Possibly a very old file handling bug in the standard c/c++ libraries

Jeffrey Lee phlamethrower@hotmail.com
Mon Apr 8 11:31:00 GMT 2002


I'm not quite sure how to put this, since I'm not even 100% sure that it's 
GCC's libraries that are to blame.

I believe there is a bug in the standard file handling code (fopen, fputc, 
etc.) when using files opened in "rb+" mode. This bug stops data being 
written to the file once certain criteria have been met - at the moment the 
exact criteria are unknown, but it is believed to be a combination of 
factors. Different compilers/libraries/systems produce different results, 
but they ALL show the bug in some form.

Using the attached test program, the bug has been seen on the following 
systems:

RISC OS, under GCC (Where it was first discovered) and LCC
Windows, under GCC and Borland
Linux, (Presumably under GCC, but it was using an older and more fiddly 
program which may have been a bit buggy)

The test program itself tests the computer by comparing the real disk-based 
output against a 'virtual' memory based file created by the program at run 
time. In order to check it wasn't a bug in my code, I also produced a 
version where RISC OS specific file handling commands (Completely bypassing 
the C libraries) where used. It was found that the low-level RISC OS file 
agreed with the memory file, so it's safe to say that the memory code is 
correct.

More details are given in the source, readme file and the log files.

My theory as to how the bug got spread around is that it was included in an 
old C library, which was then ported from system to system... I'm assuming 
it was a GCC library, but I have no way of telling.

Back to the point:

I think I've found a bug, and I want you lot (Who are presumably a lot more 
experienced in bug hunting then I am) to pull apart my code, and to find out 
whether it's my fault or someone elses ;)

Thanks,
Jeffrey

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ft.zip
Type: application/x-zip-compressed
Size: 4329 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20020408/720c209b/attachment.bin>


More information about the Gcc-bugs mailing list