The attached file that is derived from the spec 2006 benchmark suite fails if
you compile it with minimal optimization and -g.  If I remove the -g option, it
compiles fine.

I initially noticed this on powerpc64-linux-gnu, but it looked like a machine
independent bug, so I tried it on a x86_64-unknown-linux-gnu system.

The debugger trace is:
Current directory is /home/meissner/fsf-build-x86_64/trunk/gcc/
GNU gdb (GDB) Fedora (7.1-34.fc13)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /data/meissner/fsf-build-x86_64/trunk/gcc/cc1...done.
Breakpoint 1 at 0x5bc070: file /home/meissner/fsf-src/trunk/gcc/diagnostic.c,
line 878.
Breakpoint 2 at 0x5bce30: file /home/meissner/fsf-src/trunk/gcc/diagnostic.c,
line 819.
Breakpoint 3 at 0x483bd8
Breakpoint 4 at 0x483568
(gdb) r -O -g -quiet foo2.c
Starting program: /data/meissner/fsf-build-x86_64/trunk/gcc/cc1 -O -g -quiet
foo2.c

Program received signal SIGSEGV, Segmentation fault.
0x0000000000bcbb98 in get_symbol_constant_value (sym=0x7ffff06aa640) at
/home/meissner/fsf-src/trunk/gcc/gimple-fold.c:67
Missing separate debuginfos, use: debuginfo-install glibc-2.12-3.x86_64
libgcc-4.4.4-10.fc13.x86_64 libstdc++-4.4.4-10.fc13.x86_64
(gdb) where
#0  0x0000000000bcbb98 in get_symbol_constant_value (sym=0x7ffff06aa640) at
/home/meissner/fsf-src/trunk/gcc/gimple-fold.c:67
#1  0x0000000000bcbf5f in maybe_fold_reference (expr=0x7ffff05e7a80, is_lhs=0
'\000') at /home/meissner/fsf-src/trunk/gcc/gimple-fold.c:554
#2  0x0000000000bcf428 in fold_stmt_1 (gsi=0x7fffffffc3f0, inplace=<value
optimized out>) at /home/meissner/fsf-src/trunk/gcc/gimple-fold.c:1559
#3  0x0000000000a00e34 in fold_marked_statements (first=34,
statements=0x132ce20) at /home/meissner/fsf-src/trunk/gcc/tree-inline.c:4115
#4  0x0000000000a086c5 in optimize_inline_calls (fn=0x7ffff0557500) at
/home/meissner/fsf-src/trunk/gcc/tree-inline.c:4214
#5  0x00000000009dd62f in inline_transform (node=<value optimized out>) at
/home/meissner/fsf-src/trunk/gcc/ipa-inline.c:2165
#6  inline_transform (node=<value optimized out>) at
/home/meissner/fsf-src/trunk/gcc/ipa-inline.c:2139
#7  0x000000000073b619 in execute_one_ipa_transform_pass () at
/home/meissner/fsf-src/trunk/gcc/passes.c:1473
#8  execute_all_ipa_transforms () at
/home/meissner/fsf-src/trunk/gcc/passes.c:1504
#9  0x000000000083454d in tree_rest_of_compilation (fndecl=0x7ffff0557500) at
/home/meissner/fsf-src/trunk/gcc/tree-optimize.c:445
#10 0x00000000009d2326 in cgraph_expand_function (node=0x7ffff0757d70) at
/home/meissner/fsf-src/trunk/gcc/cgraphunit.c:1469
#11 0x00000000009d4d2a in cgraph_expand_all_functions () at
/home/meissner/fsf-src/trunk/gcc/cgraphunit.c:1548
#12 cgraph_optimize () at /home/meissner/fsf-src/trunk/gcc/cgraphunit.c:1804
#13 0x00000000009d528a in cgraph_finalize_compilation_unit () at
/home/meissner/fsf-src/trunk/gcc/cgraphunit.c:1012
#14 0x00000000004adfa4 in c_write_global_declarations () at
/home/meissner/fsf-src/trunk/gcc/c-decl.c:9732
#15 0x00000000007dbd5c in compile_file (argc=5, argv=0x7fffffffc978) at
/home/meissner/fsf-src/trunk/gcc/toplev.c:967
#16 do_compile (argc=5, argv=0x7fffffffc978) at
/home/meissner/fsf-src/trunk/gcc/toplev.c:2394
#17 toplev_main (argc=5, argv=0x7fffffffc978) at
/home/meissner/fsf-src/trunk/gcc/toplev.c:2435
#18 0x0000003db681ec5d in __libc_start_main () from /lib64/libc.so.6
#19 0x0000000000494f19 in _start ()
(gdb) print sym
$1 = (union tree_node *) 0x7ffff06aa640
(gdb) pt
 <var_decl 0x7ffff06aa640 cactuspriv_
    type <record_type 0x7ffff0750e70 asm_written type_0 BLK
        size <integer_cst 0x7ffff0868c30 constant 448>
        unit size <integer_cst 0x7ffff0710b18 constant 56>
        align 64 symtab -260754336 alias set -1 canonical type 0x7ffff0750e70
        fields <field_decl 0x7ffff074ca18 cctk_run_title type <pointer_type
0x7ffff0793930>
            unsigned DI file foo2.c line 98 col 9
            size <integer_cst 0x7ffff076c7a8 constant 64>
            unit size <integer_cst 0x7ffff076c7d0 constant 8>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff076c410 constant 0>
            bit offset <integer_cst 0x7ffff076cb18 constant 0> context
<record_type 0x7ffff0750e70> chain <field_decl 0x7ffff074cab0
cctk_timer_output>> context <translation_unit_decl 0x7ffff074b730 D.2979>
        chain <type_decl 0x7ffff074b508 D.2681>>
    used public external common BLK file foo2.c line 109 col 3 size
<integer_cst 0x7ffff0868c30 448> unit size <integer_cst 0x7ffff0710b18 56>
    align 64 chain <function_decl 0x7ffff0745c00 CCTK_StaggerVars>>
(gdb) print varpool_get_node (sym)
$2 = (struct varpool_node *) 0x0
(gdb) quit
A debugging session is active.

        Inferior 1 [process 20829] will be killed.

Quit anyway? (y or n) y

Debugger finished

It fails because get_symbol_constant_value calls varpool_get_node, which in
turns returns a NULL pointer.


-- 
           Summary: Segmentation violation when compiling spec source on
                    either x86 or ppc with debugging
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: meissner at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to