public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/99171] New: [10 Regression] Optional procedure call inside Open MP parallel loop produces Segmentation Fault
@ 2021-02-19 20:32 am41119 at hotmail dot com
  2021-02-20 12:22 ` [Bug fortran/99171] " dominiq at lps dot ens.fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: am41119 at hotmail dot com @ 2021-02-19 20:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99171
           Summary: [10 Regression] Optional procedure call inside Open MP
                    parallel loop produces Segmentation Fault
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: am41119 at hotmail dot com
  Target Milestone: ---

Created attachment 50226
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50226&action=edit
Output of using -save-temps during compilation

When calling a passed optional procedure inside an Open MP parallel loop (even
with OMP_NUM_THREADS=1) the address of the optional procedure is no longer set
to the actual passed procedure. Because the address of the optional procedure
is no longer correct we get a Segmentation Fault when calling it.


The below program works on GCC9 and below.


main.f90:
-----------------------------------------------
program gcc10_omp_optional_bug
    implicit none

    call function_calling_optionals(print_something)

    call function_calling_optionals_in_omp(print_something)

contains

    subroutine optional_function_template()
        implicit none
    end subroutine

    subroutine print_something()
        implicit none

        print *, "Printing Something"

    end subroutine print_something

    subroutine function_calling_optionals(optional_function)
        implicit none
        procedure(optional_function_template), optional :: optional_function

        print *, "When optional function is called without Open MP directive:"

        if (present(optional_function)) then
            call optional_function()
        end if

    end subroutine function_calling_optionals

    subroutine function_calling_optionals_in_omp(optional_function)
        implicit none
        procedure(optional_function_template), optional :: optional_function

        print *, "When optional function is called inside Open MP directive:"

        !$omp parallel 
        if (present(optional_function)) then
            call optional_function()
        end if
        !$omp end parallel

    end subroutine function_calling_optionals_in_omp


end program gcc10_omp_optional_bug


---------------------------------------------
gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
10.2.0-5ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-gcn/usr,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)

Compile Command:
gfortran main.f90 -fopenmp -o main

Execution output:

When optional function is called without Open MP directive:
Printing Something
When optional function is called inside Open MP directive:

Program received signal SIGILL: Illegal instruction.

Program received signal SIGILL: Illegal instruction.

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:

Backtrace for this error:

Backtrace for this error:

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:
#0  0x7f9e60dd1d01 in ???
#0  0x7f9e60dd1d01 in ???
#0  0x7f9e60dd1d01 in ???
#1  0x7f9e60dd0ed5 in ???
#2  0x7f9e60bc320f in ???
#3  0x7f9e5e993e27 in ???
Illegal instruction (core dumped)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-02-22 14:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 20:32 [Bug fortran/99171] New: [10 Regression] Optional procedure call inside Open MP parallel loop produces Segmentation Fault am41119 at hotmail dot com
2021-02-20 12:22 ` [Bug fortran/99171] " dominiq at lps dot ens.fr
2021-02-20 12:23 ` [Bug fortran/99171] [10/11 " dominiq at lps dot ens.fr
2021-02-22  8:40 ` rguenth at gcc dot gnu.org
2021-02-22 12:20 ` cvs-commit at gcc dot gnu.org
2021-02-22 14:01 ` cvs-commit at gcc dot gnu.org
2021-02-22 14:03 ` [Bug fortran/99171] [10/11 Regression] Optional procedure call inside OpenMP " burnus at gcc dot gnu.org
2021-02-22 14:03 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).