https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118935

--- Comment #8 from chenglulu <chenglulu at loongson dot cn> ---
(In reply to Jerry DeLisle from comment #7)
> (In reply to chenglulu from comment #1)
> > Upon debugging, it was discovered that if the '-O0' option is used to
> > compile the `find_file0` function in `libgfortran/io/unix.c`, random errors
> > occur. However, if the `find_file0` function is compiled with the '-O1'
> > option, no random errors arise.
> > 
> > The erroneous code is as follows:
> > libgfortran/io/unix.c
> > ```
> > static gfc_unit *
> > find_file0 (gfc_unit *u, FIND_FILE0_DECL)
> > {
> >  ......
> > #ifdef HAVE_WORKING_STAT
> >   if (u->s != NULL)      // The input I provided next was: At this point,
> > when making the judgment, u->s is not NULL.
> >     {
> >       unix_stream *s = (unix_stream *) (u->s);   
> >       if (st[0].st_dev == s->st_dev && st[0].st_ino == s->st_ino) // But
> > here it is NULL,u->s has been modified.
> >         return u;
> >     }
> > ```
> >
> I do not understand what you mean has been modified. If the unit structure
> passed in via the *u has had it's stream u->s assigned it means there is a
> file associated with this unit already and therefore a new unit structure
> need not be created for the file.
>
It was written as NULL. 
I'm not very familiar with this process, but in Comment6, the value of u->s
that I captured was modified by another thread.

> There were some recent changes made in the use of locks that I was not
> involved with. I wonder if the problem you are seeing is a side effect of
> those changes.
> 
> I did just now go look at rw_lock_1.f90. This is what I think.
> 
> More importantly I dont believe it is legitimate to run fortran IO in a
> libgomp environment at all.  It was and is not designed to run omp_parallel.
> The fortran language itself provides it's own parralelism and that is what
> async I/O and Coarrays is all about. The OMP directives are outside the
> scope of the fortran language, especially regarding file I/O 
> 
> My opinion is the test case should be removed as invalid.

Reply via email to