This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gfortran-4.1.0 file io bug fix


Georgy Salnikov wrote:
Dear Jerry, dear Steve,

It's me again, this time dealing with another Fortran file IO bug found in
the version gcc-4.1.0.

The file IO in gfortran-4.1.0 is now good fast, and backspace after
end-of-file condition I reported in november 2005 is now working correctly.

The problem I'd like to report now is following.

One creates a sequential unformatted file, writes several records with
various data there, and then repeatedly rewinds the file and reads these
data back again and again.

If all the records are short enough, the IO will be buffered inside the
libgfortran runtime (for the reason of speed), and this works correctly.

If the records are much longer than the buffer size (8K at the moment), the
IO requests will be done directly via libc's read/write/lseek. This seems
also to work correctly, although I am not 100% sure.

My program writes firstly a few short records, one of them containing the
size of an array which is to be written next. All these records are written
buffered. Then a rather long array is written (unbuffered because of its
length). Then again several short records, and again a long array (of
different size). And so on.

While writing all the information is written correctly, I have proven, the
file contents is right.

After rewinding the first short records and the first long array are read
correctly. But immediately after reading the long array the file pointer
s->logical_offset (libgfortran/io/unix.c) gets corrupted. As the result, the
following short records are filled with garbage, and while trying to read
the array of wrong length the program usually gets SIGSEGV or something like
this.


Georgy,


This may be PR26499.

Let me check this out this evening with the patch to pr26499 first and see if that resolves this. Then we'll go from there. Thanks for the report and test case.

Regards,

Jerry


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]