[Bug fortran/101700] New: [Coarrays] segmentation fault calling member function of derived type coarray object on remote image

harris at sourceryinstitute dot org gcc-bugzilla@gcc.gnu.org
Fri Jul 30 20:09:24 GMT 2021


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

            Bug ID: 101700
           Summary: [Coarrays] segmentation fault calling member function
                    of derived type coarray object on remote image
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: harris at sourceryinstitute dot org
  Target Milestone: ---

A segmentation fault occurs at runtime when using a member function of a
derived type to access an allocatable member variable on a remote image. That's
a lot of words, so it might be easier to explain by example.

The following program should print "1, 2, 3" twice. Instead, image 1 prints "1,
2, 3" but images 2+ crash with a segmentation fault. Note that if you replace
"mailbox[1]%stuff()" with "mailbox[1]%stuff_" then it works correctly.

module container_m
    type :: container_t
        integer, allocatable :: stuff_(:)
    contains
        procedure :: stuff
    end type
contains
    function stuff(self)
        class(container_t), intent(in) :: self
        integer, allocatable :: stuff(:)
        stuff = self%stuff_
    end function
end module

program main
    use container_m
    type(container_t) :: mailbox[*]
    if (this_image() == 1) then
        allocate(mailbox%stuff_(3))
        mailbox%stuff_ = [1, 2, 3]
    end if
    sync all
    print *, mailbox[1]%stuff()
end program



I am using OpenCoarrays 2.9.2 and gfortran 11.1.1:

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-11.1.1-20210531/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.1 20210531 (Red Hat 11.1.1-3) (GCC)


More information about the Gcc-bugs mailing list