segfault with inquire()
Andrew Benson
abenson@carnegiescience.edu
Wed Dec 4 18:08:00 GMT 2019
On Wednesday, December 4, 2019 2:03:41 PM PST Janne Blomqvist wrote:
> 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.
Thanks for this suggestion. I've tried a few variations of this idea but so
far I'm not able to reproduce the problem. Here's an example of what I've
tried, using between 16 and 128 OpenMP threads:
program inq
use OMP_Lib
implicit none
logical :: s
character(len=27) :: c
integer :: i, j
i=64
!$omp parallel private(c,j,s)
do while (.true.)
if (OMP_Get_Thread_Num() < omp_get_num_threads()/2) then
open(newUnit=j,file='test.txt',form='formatted',status='unknown')
write (c,'(e17.10)') 1.23456d0
write (j,*) trim(c)
close(j)
else
inquire(file='test.txt',exist=s)
end if
end do
!$omp end parallel
end program
I compiled this with -O0 to ensure that the inquire didn't get optimized away,
and verified that it actually calls the inquire code in libgfortran by setting
a break point in gdb. It runs without any problems.
I'll keep trying a few other variations around this idea and see if I can
reproduce the issue.
For what it's worth, in my code that triggers this problem I wrapped the
"inquire()" inside an OpenMP critical section so that no more than one OpenMP
thread can be calling inquire() at a time. So far it's been running for about
20 hours which is the longest it's run without crashing since this problem
began to appear. So, I take this as another piece of evidence that there's
some thread conflict, but it doesn't really help to narrow down where it
happens!
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