internal compiler error: in gfc_typenode_for_spec, at fortran/trans-types.c:1157

Bug #1842164 reported by saka
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-13 (Ubuntu)
Fix Released
Undecided
Unassigned
gcc-8 (Ubuntu)
Won't Fix
Undecided
Unassigned
gcc-9 (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

I think internal compiler error should not appear for compilation of module.f90.
The information about source and compiler and so on are as follows.

$ cat module.f90
module minpack
  implicit none
  type :: hybrdtype
    integer :: info=-1
    integer :: n,lwa
    double precision :: tol=1d-10
    double precision,dimension(:),allocatable :: x,fvec,wa
    procedure(),nopass,pointer :: fcn => null()
  end type
  contains
    subroutine run_hybrd(self)
      class(hybrdtype),intent(inout) :: self
      call hybrd1(self%fcn,self%n,self%x,self%fvec,self%tol,self%info,self%wa,self%lwa)
    end subroutine
end module

$ gfortran -c module.f90
module.f90:13:0:

       call hybrd1(self%fcn,self%n,self%x,self%fvec,self%tol,self%info,self%wa,self%lwa)

internal compiler error: in gfc_typenode_for_spec, at fortran/trans-types.c:1157
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.3.0-6ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --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-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --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 --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 8.3.0 (Ubuntu 8.3.0-6ubuntu1)

$ lsb_release -rd
Description: Ubuntu 19.04
Release: 19.04

$ apt-cache policy gfortran
gfortran:
  Installed: 4:8.3.0-1ubuntu3
  Candidate: 4:8.3.0-1ubuntu3
  Version table:
 *** 4:8.3.0-1ubuntu3 500
        500 http://jp.archive.ubuntu.com/ubuntu disco/main amd64 Packages
        100 /var/lib/dpkg/status

CVE References

Revision history for this message
In , Gscfq (gscfq) wrote :

Without a program statement :

$ cat z1.f90
integer(len((c)) :: n
end

$ gfortran-9-20181216 -c z1.f90
$ gfortran-9-20181216 -c z1.f90 -fimplicit-none
z1.f90:1:0:

    1 | integer(len((c)) :: n
      |
internal compiler error: in gfc_typenode_for_spec, at fortran/trans-types.c:1120
0x78e59d gfc_typenode_for_spec(gfc_typespec*, int)
        ../../gcc/fortran/trans-types.c:1120
0x78c1f6 gfc_sym_type(gfc_symbol*)
        ../../gcc/fortran/trans-types.c:2243
0x71af9e gfc_get_symbol_decl(gfc_symbol*)
        ../../gcc/fortran/trans-decl.c:1696
0x71ea47 generate_local_decl
        ../../gcc/fortran/trans-decl.c:5600
0x6d3d12 do_traverse_symtree
        ../../gcc/fortran/symbol.c:4151
0x71ff9c generate_local_vars
        ../../gcc/fortran/trans-decl.c:5800
0x71ff9c gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.c:6444
0x69d7c6 translate_all_program_units
        ../../gcc/fortran/parse.c:6128
0x69d7c6 gfc_parse_file()
        ../../gcc/fortran/parse.c:6331
0x6e6fcf gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:204

---

Invalid syntax also silently accepted :

$ cat z3.f90
integer(m::n
end

$ gfortran-9-20181216 -c z3.f90
$ gfortran-9-20181216 -c z3.f90 -fimplicit-none
z3.f90:1:0:

    1 | integer(m::n
      |
internal compiler error: in gfc_typenode_for_spec, at fortran/trans-types.c:1120
#...

Revision history for this message
In , Gscfq (gscfq) wrote :

Detected :

$ cat z2.f90
program p
integer(len((c)) :: n
end

$ cat z5.f90
implicit none
integer(len((c)) :: n
end

$ gfortran-9-20181216 -c z2.f90 -fimplicit-none
z2.f90:2:14:

    2 | integer(len((c)) :: n
      | 1
Error: Symbol 'c' at (1) has no IMPLICIT type

Revision history for this message
In , Dominiq (dominiq) wrote :

Confirmed from at least 4.8 up to trunk (9.0).

summary:
Revision history for this message
Matthias Klose (doko) wrote :
Changed in gcc-8 (Ubuntu):
status: New → Confirmed
Changed in gcc-9 (Ubuntu):
status: New → Confirmed
Changed in gcc:
importance: Unknown → Medium
status: Unknown → Confirmed
Matthias Klose (doko)
Changed in gcc-8 (Ubuntu):
status: Confirmed → Triaged
Changed in gcc-9 (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
In , Anlauf-o (anlauf-o) wrote :

I'm testing the following patch:

diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 1de2b231242..2162b62608a 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -3366,6 +3372,7 @@ close_brackets:
       else
  gfc_error ("Missing right parenthesis at %C");
       m = MATCH_ERROR;
+ goto no_match;
     }
   else
      /* All tests passed. */
@@ -4716,6 +4723,9 @@ get_kind:
       return MATCH_ERROR;
     }

+ if (m == MATCH_ERROR)
+ return MATCH_ERROR;
+
   /* Defer association of the KIND expression of function results
      until after USE and IMPORT statements. */
   if ((gfc_current_state () == COMP_NONE && gfc_error_flag_test ())

Revision history for this message
In , Anlauf-o (anlauf-o) wrote :
Changed in gcc:
status: Confirmed → In Progress
Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The master branch has been updated by Harald Anlauf <email address hidden>:

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

commit r14-1477-gff8f45d20f9ea6acc99442ad29212d177f58e8fe
Author: Harald Anlauf <email address hidden>
Date: Thu Jun 1 23:04:30 2023 +0200

    Fortran: force error on bad KIND specifier [PR88552]

    gcc/fortran/ChangeLog:

            PR fortran/88552
            * decl.cc (gfc_match_kind_spec): Use error path on missing right
            parenthesis.
            (gfc_match_decl_type_spec): Use error return when an error occurred
            during matching a KIND specifier.

    gcc/testsuite/ChangeLog:

            PR fortran/88552
            * gfortran.dg/pr88552.f90: New test.

Revision history for this message
In , Anlauf-o (anlauf-o) wrote :

Fixed for gcc-14. Closing.

Thanks for the report!

Changed in gcc:
status: In Progress → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

won't fix in older GCC version,

Changed in gcc-13 (Ubuntu):
status: New → In Progress
Changed in gcc-8 (Ubuntu):
status: Triaged → Won't Fix
Changed in gcc-9 (Ubuntu):
status: Triaged → Won't Fix
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-13 - 13.2.0-4ubuntu1

---------------
gcc-13 (13.2.0-4ubuntu1) mantic; urgency=medium

  * Merge with Debian; remaining changes:
    - Build from upstream sources.

gcc-13 (13.2.0-4) unstable; urgency=medium

  * Update to git 20230913 from the gcc-13 branch.
    - Fix PR target/96762 (PPC), PR target/111340 (x86),
      PR target/111306 (x86), PR target/111335 (x86),
      PR modula2/111330.
    - Address stack protector and stack clash protection weaknesses
      on AArch64. CVE-2023-4039.

  [ Matthias Klose ]
  * Fix PR fortran/88552, taken from the trunk. LP: #1842164.

  [ Aurelien Jarno ]
  * Update libasan8 symbols for riscv64.

 -- Matthias Klose <email address hidden> Wed, 13 Sep 2023 13:28:29 +0200

Changed in gcc-13 (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.