From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3530 invoked by alias); 9 Mar 2006 14:28:07 -0000 Received: (qmail 3493 invoked by uid 22791); 9 Mar 2006 14:28:06 -0000 X-Spam-Check-By: sourceware.org Received: from vms044pub.verizon.net (HELO vms044pub.verizon.net) (206.46.252.44) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 09 Mar 2006 14:28:06 +0000 Received: from [192.168.1.2] ([71.115.216.36]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IVV00ADD6URL9N0@vms044.mailsrvcs.net>; Thu, 09 Mar 2006 08:28:04 -0600 (CST) Date: Thu, 09 Mar 2006 14:28:00 -0000 From: Jerry DeLisle Subject: Re: gfortran-4.1.0 file io bug fix In-reply-to: To: Georgy Salnikov Cc: sgk@troutmask.apl.washington.edu, fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Message-id: <44103B32.3010907@verizon.net> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2006-03/txt/msg00517.txt.bz2 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