https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125113
Bug ID: 125113
Summary: [coarray] Segfault accessing remote image; regression
from 13.3
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: neil.n.carlson at gmail dot com
Target Milestone: ---
This reproducer extends that of PR 125021 and compiles with the 17.0 fix for
it, but it gives a run time segfault. This compiles and runs correctly with
gfortran 13.3 and opencoarrays.
integer, allocatable, target :: src(:)
integer :: dest(2)
integer :: i, first_gid, last_gid
type :: box
integer, pointer :: data(:) => null()
end type
type(box), allocatable :: buffer[:]
if (this_image() == 1) then
src = [(i, i = 1, 2*num_images())]
else
allocate(src(0))
end if
first_gid = 1+2*(this_image()-1)
last_gid = 2*this_image()
allocate(buffer[*])
buffer%data => src
sync all
dest = buffer[1]%data(first_gid:last_gid)
if (any(dest /= [first_gid, last_gid])) error stop
end
$ gfortran -g -fcoarray=lib gfortran-20260429.f90 -lcaf_shmem
$ GFORTRAN_NUM_IMAGES=2 ./a.out
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7f5e4eaed44f in ???
#1 0x401949 in _caf_accessor_main_buffer_1
at
/home/nnc/Fortran/fortran-compiler-tests/gfortran-bugs/tmp/gfortran-20260429.f90:42
#2 0x4021dd in MAIN__
at
/home/nnc/Fortran/fortran-compiler-tests/gfortran-bugs/tmp/gfortran-20260429.f90:42
#3 0x40232c in main
at
/home/nnc/Fortran/fortran-compiler-tests/gfortran-bugs/tmp/gfortran-20260429.f90:45
ERROR: Image 2(pid: 3927410) failed with signal 11, exitstatus 0.