ICE in lto1: Os + C++11 has missing symbol table nodes during SSA CCP pass
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Fix Released
|
Low
|
Terry Guo | ||
4.9 |
Fix Released
|
Low
|
Terry Guo |
Bug Description
Toolchain:
arm-none-eabi-g++ (GNU Tools for ARM Embedded Processors) 4.8.3 20131129 (release) [ARM/embedded-
Host:
Darwin andrewre-osx.local 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-
I've noticed segfaults in g++ while linking a large project together, but only while -flto was enabled. Removing references to these large objects fixed the segfault. Using the -flto-partition
The segfault only occurs with the -std=c++11 option, and with some optimization option greater than O0. The segfault also only occurs when the A and B global objects in ice_lto.ii are declared with the const qualifier. I took the liberty of using -v -save-temps to generate a backtrace, listed below.
-flto-partition did not exist back in 4.7.4, but linking with all the original libraries never produced an ICE, so I believe this is a regression.
To compile:
arm-none-eabi-g++ -Os -flto -flto-partition=max -std=c++11 --specs=
Crash:
lto1 crashes inside gimple-fold.c, in can_refer_
if (!from_decl
|| TREE_CODE (from_decl) != VAR_DECL
|| !DECL_EXTERNAL (from_decl)
|| (flag_ltrans
&& symtab_get_node (from_decl)
return true;
symtab_
I am not entirely sure what is happening, but I'm guessing the optimizer folds a call into a virtual function when it does its constant expression pass, but that method has been removed?
Faulting output:
ice_lto.cpp: In function 'main':
ice_lto.cpp:41:5: internal compiler error: Segmentation fault: 11
int main(void)
^
ice_lto.cpp:41:5: internal compiler error: Abort trap: 6
arm-none-eabi-g++: internal compiler error: Abort trap: 6 (program lto1)
lto-wrapper: arm-none-eabi-g++ terminated with signal 6 [Abort trap: 6]
/opt/arm-
collect2: error: ld returned 1 exit status
The segfault occurs in lto1, with the following backtrace
(gdb) run -quiet -dumpbase ccr25Vgz.ltrans0.o -auxbase-strip /var/folders/
Starting program: /opt/arm-
GNU GIMPLE (GNU Tools for ARM Embedded Processors) version 4.8.3 20131129 (release) [ARM/embedded-
compiled by GNU C version 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-
GNU GIMPLE (GNU Tools for ARM Embedded Processors) version 4.8.3 20131129 (release) [ARM/embedded-
compiled by GNU C version 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_
0x00000001003aa4eb in can_refer_
70 && symtab_get_node (from_decl)
(gdb) bt
#0 0x00000001003aa4eb in can_refer_
#1 0x00000001003aa016 in canonicalize_
#2 0x00000001003b1ae3 in fold_ctor_reference (type=0x14206a540, ctor=<value temporarily unavailable, due to optimizations>, offset=0, size=32, from_decl=
#3 0x00000001003b23b1 in fold_ctor_reference (type=0x14206a540, ctor=<value temporarily unavailable, due to optimizations>, offset=<value temporarily unavailable, due to optimizations>, size=32, from_decl=
#4 0x00000001003b139a in fold_const_
#5 0x00000001003b0ebb in gimple_
#6 0x00000001006ac957 in ccp_fold () at /Users/
#7 0x00000001006ac957 in evaluate_stmt (stmt=0x142073d20) at /Users/
#8 0x00000001006b00a1 in visit_assignment (stmt=0x142073d20, output_
#9 0x00000001006aaf56 in ccp_visit_stmt (stmt=0x142073d20, taken_edge_p=<value temporarily unavailable, due to optimizations>, output_
#10 0x00000001007258fa in simulate_stmt (stmt=0x142073d20) at /Users/
#11 0x00000001007248b8 in ssa_propagate (visit_stmt=<value temporarily unavailable, due to optimizations>, visit_phi=<value temporarily unavailable, due to optimizations>) at /Users/
#12 0x00000001006a983b in do_ssa_ccp () at /Users/
#13 0x0000000100515d15 in execute_one_pass () at /Users/
#14 0x000000010051657d in execute_pass_list (pass=<value temporarily unavailable, due to optimizations>) at /Users/
#15 0x000000010051658f in execute_pass_list (pass=<value temporarily unavailable, due to optimizations>) at /Users/
#16 0x000000010021b559 in _ZL23invoke_
#17 0x000000010021b559 in expand_function (node=0x142074000) at /Users/
#18 0x000000010021cd1f in expand_
#19 0x000000010021cd1f in compile () at /Users/
#20 0x0000000100028cf6 in lto_main () at /Users/
#21 0x00000001005ce85a in _ZL11timevar_
#22 0x00000001005ce85a in compile_file () at /Users/
#23 0x00000001005ce68f in toplev_main (argc=15, argv=0x141103d00) at /Users/
#24 0x00007fff8cd575fd in start ()
Any advice?
Changed in gcc-arm-embedded: | |
assignee: | nobody → Terry Guo (terry.guo) |
Thank you for reporting issue and providing the investigation and reduced cases. Those are very helpful for us to analyze it. I can reproduce this issue on Windows and will look into it.