http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59612

            Bug ID: 59612
           Summary: iso_fortran_env segfaults with -fdump-fortran-original
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkoenig at gcc dot gnu.org

ig25@linux-fd1f:~/Krempel/NoRange> cat iso.f90
program main
  use iso_fortran_env
end program main
ig25@linux-fd1f:~/Krempel/NoRange> gfortran -fdump-fortran-original iso.f90 

Namespace: A-H: (REAL 4) I-N: (INTEGER 4) O-Z: (REAL 4)
procedure name = main
  symtree: 'Lock_type'   || symbol: 'lock_type'    
    type spec : (UNKNOWN 0)
    attributes: (DERIVED  USE-ASSOC(iso_fortran_env))
  symtree: 'atomic_int_kind'|| symbol: 'atomic_int_kind' 
    type spec : (INTEGER 4)
    attributes: (PARAMETER  USE-ASSOC(iso_fortran_env))
    value: 4
  symtree: 'atomic_logical_kind'|| symbol: 'atomic_logical_kind' 
    type spec : (INTEGER 4)
    attributes: (PARAMETER  USE-ASSOC(iso_fortran_env))
    value: 4
  symtree: 'character_kinds'|| symbol: 'character_kinds' 
    type spec : (INTEGER 4)
    attributes: (PARAMETER  DIMENSION USE-ASSOC(iso_fortran_env))
    value: (/ 1 , 4 /)
    Array spec:(1 [0] AS_EXPLICIT 1 2 )
  symtree: 'character_storage_size'|| symbol: 'character_storage_size' 
    type spec : (INTEGER 4)
    attributes: (PARAMETER  USE-ASSOC(iso_fortran_env))
    value: 8
  symtree: 'compiler_options'|| symbol: 'compiler_options' 
f951: interner Compiler-Fehler: Speicherzugriffsfehler
0x9f9dff crash_signal
        ../../trunk/gcc/toplev.c:336
0x5635bc show_typespec
        ../../trunk/gcc/fortran/dump-parse-tree.c:113
0x566a3c show_symbol
        ../../trunk/gcc/fortran/dump-parse-tree.c:841
0x566a3c show_symtree
        ../../trunk/gcc/fortran/dump-parse-tree.c:1000
0x5dcdc9 do_traverse_symtree
        ../../trunk/gcc/fortran/symbol.c:3581
0x566571 show_namespace
        ../../trunk/gcc/fortran/dump-parse-tree.c:2284
0x5b09ee gfc_parse_file()
        ../../trunk/gcc/fortran/parse.c:4728
0x5ee895 gfc_be_parse_file
        ../../trunk/gcc/fortran/f95-lang.c:188
Bitte senden Sie einen vollständigen Fehlerbericht auf Englisch ein;
bearbeiten Sie die Quellen zunächst mit einem Präprozessor, wenn es
dienlich ist.
Please include the complete backtrace with any bug report.
Siehe <http://gcc.gnu.org/bugs.html> für nähere Anweisungen.
ig25@linux-fd1f:~/Krempel/NoRange> gfortran -v
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/ig25/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Ziel: x86_64-unknown-linux-gnu
Konfiguriert mit: ../trunk/configure --prefix=/home/ig25
--enable-languages=c,fortran,c++
Thread-Modell: posix
gcc-Version 4.9.0 20131225 (experimental) (GCC) 

valgrind shows:
==13350== Invalid read of size 8
==13350==    at 0x5635BC: show_typespec(gfc_typespec*) (dump-parse-tree.c:113)
==13350==    by 0x566A3C: show_symtree(gfc_symtree*) (dump-parse-tree.c:841)
==13350==    by 0x5DCDC9: do_traverse_symtree(gfc_symtree*, void
(*)(gfc_symtree*), void (*)(gfc_symbol*)) (symbol.c:3581)
==13350==    by 0x566571: show_namespace(gfc_namespace*)
(dump-parse-tree.c:2284)
==13350==    by 0x5B09EE: gfc_parse_file() (parse.c:4728)
==13350==    by 0x5EE895: gfc_be_parse_file() (f95-lang.c:188)
==13350==    by 0x9F9E25: compile_file() (toplev.c:547)
==13350==    by 0x9FBDF7: toplev_main(int, char**) (toplev.c:1887)
==13350==    by 0x5A54BE4: (below main) (in /lib64/libc-2.18.so)
==13350==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

gdb shows that the typespec for compiler_options is NULL:

 symtree: 'compiler_options'|| symbol: 'compiler_options' 

Program received signal SIGSEGV, Segmentation fault.
0x00000000005635bc in show_typespec (ts=0x0) at
../../trunk/gcc/fortran/dump-parse-tree.c:113
113           show_expr (ts->u.cl->length);
(gdb) up
#1  0x0000000000566a3d in show_symbol (sym=0x184ee10) at
../../trunk/gcc/fortran/dump-parse-tree.c:841
841       show_typespec (&sym->ts);
(gdb) p sym
$1 = (gfc_symbol *) 0x184ee10
(gdb) p *sym
$2 = {name = 0x7ffff6c53738 "compiler_options", module = 0x7ffff6d33340
"iso_fortran_env", declared_at = {nextc = 0x17dcb68, lb = 0x17dcb30}, ts = {
    type = BT_CHARACTER, kind = 1, u = {derived = 0x0, cl = 0x0, pad = 0},
interface = 0x0, is_c_interop = 0, is_iso_c = 0, f90_type = BT_UNKNOWN, 
    deferred = false}, attr = {allocatable = 0, dimension = 0, codimension = 0,
external = 0, intrinsic = 1, optional = 0, pointer = 0, target = 0, 
    value = 0, volatile_ = 0, temporary = 0, dummy = 0, result = 0, assign = 0,
threadprivate = 0, not_always_present = 0, implied_index = 0, 
    subref_array_pointer = 0, proc_pointer = 0, asynchronous = 0, contiguous =
0, class_pointer = 0, save = SAVE_NONE, data = 0, is_protected = 0, 
    use_assoc = 1, use_only = 0, use_rename = 0, imported = 0, host_assoc = 0,
in_namelist = 0, in_common = 0, in_equivalence = 0, function = 1, 
    subroutine = 0, procedure = 0, generic = 0, generic_copy = 0, implicit_type
= 0, untyped = 0, is_bind_c = 0, extension = 0, is_class = 0, 
    class_ok = 0, vtab = 0, vtype = 0, is_c_interop = 0, is_iso_c = 0, sequence
= 0, elemental = 0, pure = 1, recursive = 0, unmaskable = 0, masked = 0, 
    contained = 0, mod_proc = 0, abstract = 0, public_used = 0, implicit_pure =
0, noreturn = 0, entry = 0, entry_master = 0, mixed_entry_master = 0, 
    always_explicit = 0, artificial = 0, referenced = 0, is_main_program = 0,
access = ACCESS_UNKNOWN, intent = INTENT_UNKNOWN, flavor = FL_PROCEDURE, 
    if_source = IFSRC_DECL, proc = PROC_UNKNOWN, cray_pointer = 0, cray_pointee
= 0, alloc_comp = 0, pointer_comp = 0, proc_pointer_comp = 0, 
    private_comp = 0, zero_comp = 0, coarray_comp = 0, lock_comp = 0,
defined_assign_comp = 0, unlimited_polymorphic = 0, select_type_temporary = 0, 
    associate_var = 0, ext_attr = 0, volatile_ns = 0x0, asynchronous_ns = 0x0},
generic = 0x0, component_access = ACCESS_UNKNOWN, formal = 0x0, 
  formal_ns = 0x0, f2k_derived = 0x0, value = 0x0, as = 0x0, result = 0x0,
components = 0x0, cp_pointer = 0x0, entry_id = 0, hash_value = 0, 
  common_next = 0x0, common_head = 0x0, dummy_order = 0, namelist = 0x0,
namelist_tail = 0x0, old_symbol = 0x0, tlink = 0x0, mark = 1, gfc_new = 0, 
  equiv_built = 0, forall_index = 0, resolved = 1, refs = 1, ns = 0x17d71b0,
backend_decl = 0x0, from_intmod = INTMOD_ISO_FORTRAN_ENV, intmod_sym_id = 26, 
  binding_label = 0x0, common_block = 0x0, assoc = 0x0}

Reply via email to