public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic
@ 2020-06-03 15:13 vincent.lafage at in2p3 dot fr
  2020-06-03 15:43 ` [Bug fortran/95500] " kargl at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vincent.lafage at in2p3 dot fr @ 2020-06-03 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95500
           Summary: Segfault compiling extra interface on intrinsic
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent.lafage at in2p3 dot fr
  Target Milestone: ---

Created attachment 48669
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48669&action=edit
Source file for the minimal test case

When compiling the following sample minimal test case (named
test_intrinsic.f90)

  program test_intrinsic
    implicit none
    intrinsic :: alog
    intrinsic :: dlog
    real (4), parameter :: one = 1

    interface ln
       procedure :: alog, dlog
    end interface ln

    write (*, *) 'ln  1', ln (one)
  end program test_intrinsic

through
  $ gfortran -Wall -Wextra test_intrinsic.f90

I ended-up with the following failure:

test_intrinsic.f90:11:0:

   11 |   write (*, *) 'ln  1', ln (one)
      | 
internal compiler error: Segmentation fault
0x7f4068d23fdf ???
       
/build/glibc-TrjWJf/glibc-2.29/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f4068d10bba __libc_start_main
        ../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-9/README.Bugs> for instructions.

I confirm that it is a longstanding bug, as I get the same problem with
gfortran-4.9, gfortran-5, gfortran-6, gfortran-7, gfortran-8 as well.
(Trying with other brands of compiler, g95, pgfortran, flang, and an old ifort
reported error without segfaulting)

Getting the backtrace with valgrind:
$ valgrind -s -v --leak-check=full --show-reachable=yes --show-leak-kinds=all
--leak-resolution=high --num-callers=100 --trace-children=yes --track-fds=yes
--log-file=Valgrind_gfortran_report4.txt gfortran -v -Wall -Wextra
test_intrinsic.f90
…
==891734== 1 errors in context 1 of 1:
==891734== Invalid read of size 1
==891734==    at 0x135083C: gfc_conv_expr_reference(gfc_se*, gfc_expr*, bool)
(in /usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x1385548: gfc_trans_transfer(gfc_code*) (in
/usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x130D669: ??? (in /usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x137FA9C: ??? (in /usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x130D689: ??? (in /usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x133F1F5: gfc_generate_function_code(gfc_namespace*) (in
/usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x128CF26: gfc_parse_file() (in
/usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x1309D9F: ??? (in /usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0x143CC26: ??? (in /usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0xD9A415: toplev::main(int, char**) (in
/usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==    by 0xD9C4CE: main (in /usr/lib/gcc/x86_64-linux-gnu/9/f951)
==891734==  Address 0x50 is not stack'd, malloc'd or (recently) free'd
==891734== 
==891734== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)


$ gfortran --version
GNU Fortran (Debian 9.2.1-4) 9.2.1 20190821

$ uname -a
Linux serval 5.4.0-0.bpo.4-amd64 #1 SMP Debian 5.4.19-1~bpo10+1 (2020-03-09)
x86_64 GNU/Linux

$ gfortran -v -Wall -Wextra test_intrinsic.f90
Driving: gfortran -v -Wall -Wextra test_intrinsic.f90 -l gfortran -l m
-shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 9.2.1-4'
--with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--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-bootstrap --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
--with-target-system-zlib=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,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
gcc version 9.2.1 20190821 (Debian 9.2.1-4) 
COLLECT_GCC_OPTIONS='-v' '-Wall' '-Wextra' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/f951 test_intrinsic.f90 -quiet -dumpbase
test_intrinsic.f90 -mtune=generic -march=x86-64 -auxbase test_intrinsic -Wall
-Wextra -version -fintrinsic-modules-path
/usr/lib/gcc/x86_64-linux-gnu/9/finclude -o /tmp/ccgGzgc9.s
GNU Fortran (Debian 9.2.1-4) version 9.2.1 20190821 (x86_64-linux-gnu)
        compiled by GNU C version 9.2.1 20190821, GMP version 6.1.2, MPFR
version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (Debian 9.2.1-4) version 9.2.1 20190821 (x86_64-linux-gnu)
        compiled by GNU C version 9.2.1 20190821, GMP version 6.1.2, MPFR
version 4.0.2, MPC version 1.1.0, isl version isl-0.20-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
test_intrinsic.f90:11:0:

   11 |   write (*, *) 'ln  1', ln (one)
      | 
internal compiler error: Segmentation fault
0x7fd0b7015fdf ???
       
/build/glibc-TrjWJf/glibc-2.29/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7fd0b7002bba __libc_start_main
        ../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-9/README.Bugs> for instructions.

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

* [Bug fortran/95500] Segfault compiling extra interface on intrinsic
  2020-06-03 15:13 [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic vincent.lafage at in2p3 dot fr
@ 2020-06-03 15:43 ` kargl at gcc dot gnu.org
  2020-06-04 18:53 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-06-03 15:43 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Last reconfirmed|                            |2020-06-03
                 CC|                            |kargl at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from kargl at gcc dot gnu.org ---
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c    (revision 280157)
+++ gcc/fortran/trans-expr.c    (working copy)
@@ -8789,6 +8789,7 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr,

   if (expr->expr_type == EXPR_FUNCTION
       && ((expr->value.function.esym
+          && expr->value.function.esym->result
           && expr->value.function.esym->result->attr.pointer
           && !expr->value.function.esym->result->attr.dimension)
          || (!expr->value.function.esym && !expr->ref

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

* [Bug fortran/95500] Segfault compiling extra interface on intrinsic
  2020-06-03 15:13 [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic vincent.lafage at in2p3 dot fr
  2020-06-03 15:43 ` [Bug fortran/95500] " kargl at gcc dot gnu.org
@ 2020-06-04 18:53 ` anlauf at gcc dot gnu.org
  2020-06-04 19:01 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-06-04 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
Will commit Steve's fix as obvious, with a testcase.

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

* [Bug fortran/95500] Segfault compiling extra interface on intrinsic
  2020-06-03 15:13 [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic vincent.lafage at in2p3 dot fr
  2020-06-03 15:43 ` [Bug fortran/95500] " kargl at gcc dot gnu.org
  2020-06-04 18:53 ` anlauf at gcc dot gnu.org
@ 2020-06-04 19:01 ` cvs-commit at gcc dot gnu.org
  2020-06-05 18:46 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-04 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:8c727bdf4acf28c8315b119a1c8f6d6af745c2af

commit r11-953-g8c727bdf4acf28c8315b119a1c8f6d6af745c2af
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Jun 4 21:00:33 2020 +0200

    PR fortran/95500 - Segfault compiling extra interface on intrinsic

    Converting an expression so that it can be passed by reference could
    result in a NULL pointer dereference.

    2020-06-04  Steven G. Kargl  <kargl@gcc.gnu.org>
                Harald Anlauf  <anlauf@gmx.de>

    gcc/fortran/
            PR fortran/95500
            * trans-expr.c (gfc_conv_expr_reference): Do not dereference NULL
            pointer.

    gcc/testsuite/
            PR fortran/95500
            * gfortran.dg/pr95500.f90: New test.

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

* [Bug fortran/95500] Segfault compiling extra interface on intrinsic
  2020-06-03 15:13 [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic vincent.lafage at in2p3 dot fr
                   ` (2 preceding siblings ...)
  2020-06-04 19:01 ` cvs-commit at gcc dot gnu.org
@ 2020-06-05 18:46 ` cvs-commit at gcc dot gnu.org
  2020-06-05 18:51 ` cvs-commit at gcc dot gnu.org
  2020-06-05 18:52 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-05 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:4b3ea558da6479dabe5841bcb0f6bad3f7fea858

commit r10-8250-g4b3ea558da6479dabe5841bcb0f6bad3f7fea858
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Jun 4 21:00:33 2020 +0200

    PR fortran/95500 - Segfault compiling extra interface on intrinsic

    Converting an expression so that it can be passed by reference could
    result in a NULL pointer dereference.

    2020-06-04  Steven G. Kargl  <kargl@gcc.gnu.org>
                Harald Anlauf  <anlauf@gmx.de>

    gcc/fortran/
            PR fortran/95500
            * trans-expr.c (gfc_conv_expr_reference): Do not dereference NULL
            pointer.

    gcc/testsuite/
            PR fortran/95500
            * gfortran.dg/pr95500.f90: New test.

    (cherry picked from commit 8c727bdf4acf28c8315b119a1c8f6d6af745c2af)

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

* [Bug fortran/95500] Segfault compiling extra interface on intrinsic
  2020-06-03 15:13 [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic vincent.lafage at in2p3 dot fr
                   ` (3 preceding siblings ...)
  2020-06-05 18:46 ` cvs-commit at gcc dot gnu.org
@ 2020-06-05 18:51 ` cvs-commit at gcc dot gnu.org
  2020-06-05 18:52 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-05 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:fa0d6c132c8fd7deb118f8309aa9dfe41a88e840

commit r9-8653-gfa0d6c132c8fd7deb118f8309aa9dfe41a88e840
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Jun 4 21:00:33 2020 +0200

    PR fortran/95500 - Segfault compiling extra interface on intrinsic

    Converting an expression so that it can be passed by reference could
    result in a NULL pointer dereference.

    2020-06-04  Steven G. Kargl  <kargl@gcc.gnu.org>
                Harald Anlauf  <anlauf@gmx.de>

    gcc/fortran/
            PR fortran/95500
            * trans-expr.c (gfc_conv_expr_reference): Do not dereference NULL
            pointer.

    gcc/testsuite/
            PR fortran/95500
            * gfortran.dg/pr95500.f90: New test.

    (cherry picked from commit 8c727bdf4acf28c8315b119a1c8f6d6af745c2af)

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

* [Bug fortran/95500] Segfault compiling extra interface on intrinsic
  2020-06-03 15:13 [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic vincent.lafage at in2p3 dot fr
                   ` (4 preceding siblings ...)
  2020-06-05 18:51 ` cvs-commit at gcc dot gnu.org
@ 2020-06-05 18:52 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-06-05 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from anlauf at gcc dot gnu.org ---
Fixed on master for GCC-11, and backported to 10-branch and 9-branch.
Closing.

Thanks for the report!

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

end of thread, other threads:[~2020-06-05 18:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 15:13 [Bug fortran/95500] New: Segfault compiling extra interface on intrinsic vincent.lafage at in2p3 dot fr
2020-06-03 15:43 ` [Bug fortran/95500] " kargl at gcc dot gnu.org
2020-06-04 18:53 ` anlauf at gcc dot gnu.org
2020-06-04 19:01 ` cvs-commit at gcc dot gnu.org
2020-06-05 18:46 ` cvs-commit at gcc dot gnu.org
2020-06-05 18:51 ` cvs-commit at gcc dot gnu.org
2020-06-05 18:52 ` anlauf 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).