segfault with inquire()

Janne Blomqvist blomqvist.janne@gmail.com
Wed Dec 4 12:03:00 GMT 2019


On Tue, Dec 3, 2019 at 10:10 PM Andrew Benson
<abenson@carnegiescience.edu> wrote:
>
> On Tuesday, December 3, 2019 7:48:24 PM PST N.M. Maclaren wrote:
> > On Dec 3 2019, Andrew Benson wrote:
> > > I'm attempting to track down a segfault that seems to be associated with
> > > the inquire() statement. Unfortunately it only happens when running a
> > > massively parallel code, using both MPI and OpenMP parallelism, and I
> > > have as yet been unable to make a simple test case that reproduces the
> > > bug. I also haven't convinced myself 100% that the problem is really in
> > > the libgfortran code for inquire() and not in my own code, but since it
> > > seems that inquire() should be thread safe it seems that the problem at
> > > least could be in libgfortran.
> >
> > Well, that's an assumption and a half!  A good principle is to assume that
> > no I/O is thread-safe, not even in C/C++/POSIX (which specify it to be).
> > If you had a race condition between INQUIRE and anything else that changed
> > what files were open or anything that operated on the file you looked at,
> > I would expect trouble.
>
> Agreed - it is an assumption. However, my assumption is based on previous
> discussion around a bug that I reported:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78387#c3
>
> which lead me to expect that I/O operations should actually be thread safe in
> gfortran.

That is correct. What you have described quite clearly looks like a
bug that should be fixed.

I can't immediately see what's wrong based on your stack traces, but
in your shoes I would try to create an OpenMP testcase (forget MPI,
that's not relevant here AFAICS) where part of the threads run INQUIRE
and the other threads do internal IO, run it with different numbers of
threads and see if you can recreate it.


-- 
Janne Blomqvist



More information about the Fortran mailing list