segfault with inquire()
Andrew Benson
abenson@carnegiescience.edu
Tue Dec 3 20:10:00 GMT 2019
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.
However, I certainly agree that this is an assumption since even if they're
intended to be thread safe they may not actually be if there is a bug. So, I'm
in the process of testing this now by synchronizing the relevant I/O.
Thanks,
Andrew
--
* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html
* Galacticus: https://github.com/galacticusorg/galacticus
More information about the Fortran
mailing list