This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: [PATCH, libgfortran] PR 25697 FIX Segmentation fault/ Bad Address on unformatted read


Jerry DeLisle wrote:

BTW on pr25697 I have tracked it partly to differences between the small buffer (8192 bytes) and the large buffer logic of fd_alloc. Hope to look at it some more tonight.


I am having a difficult time with this bug. Its really in two parts. The first part which I submitted before and then withdrew I am attaching again. I would like to commit this first part by itself since it fixes the original test case for this bug and it is needed. I will also commit the test case for it.

The second part is a different problem in unix.c (fd_alloc). When I 'fix' this second part I get regression on gfortran.dg/direct_io_2.f90. I try to undo the regression and the new test case fails. Very frustrating and the code is difficult to figure out. I would like to open a new PR for this second part and copy that test case over. I will also include the block of code where I am stuck. (The real fix could very well need to be somewhere else)

I will keep working on it, but someone else might see something I am not.

Regards,

Jerry

2006-01-17 Jerry DeLisle <jvdelisle@gcc.gnu.org>

    PR libgfortran/25697
    * io/transfer.c (us_read): Detect end of file condition from previous
    operations and bail out (no need to pre-position).

Attachment: read_eof.f90
Description: application/extension-f90

Index: io/transfer.c
===================================================================
*** io/transfer.c	(revision 109491)
--- io/transfer.c	(working copy)
*************** us_read (st_parameter_dt *dtp)
*** 1205,1215 ****
    int n;
    gfc_offset i;
  
    n = sizeof (gfc_offset);
    p = salloc_r (dtp->u.p.current_unit->s, &n);
  
    if (n == 0)
!     return;  /* end of file */
  
    if (p == NULL || n != sizeof (gfc_offset))
      {
--- 1220,1236 ----
    int n;
    gfc_offset i;
  
+   if (dtp->u.p.current_unit->endfile == AT_ENDFILE)
+     return;
+ 
    n = sizeof (gfc_offset);
    p = salloc_r (dtp->u.p.current_unit->s, &n);
  
    if (n == 0)
!     {
!       dtp->u.p.current_unit->endfile = AT_ENDFILE;
!       return;  /* end of file */
!     }
  
    if (p == NULL || n != sizeof (gfc_offset))
      {

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