evans:/abuild/jh/sqlite-3.6.23.1/:[0]# /abuild/jh/trunk-install/bin/gcc -fPIC -O0 -fwhopr=24 -fno-strict-aliasing -pthread -pipe -O2 shell.c sqlite3.c -ldl -g ; echo "create table memos(text, priority INTEGER);" | ./a.out Segmentation fault (core dumped) evans:/abuild/jh/sqlite-3.6.23.1/:[139]# /abuild/jh/trunk-install/bin/gcc -fPIC -O0 -fwhopr=24 -fno-strict-aliasing -pthread -pipe -O2 shell.c sqlite3.c -ldl -g -fno-ipa-sra ; echo "create table memos(text, priority INTEGER);" | ./a.out evans:/abuild/jh/sqlite-3.6.23.1/:[139]# /abuild/jh/trunk-install/bin/gcc -fPIC -O0 -fno-strict-aliasing -pthread -pipe -O2 shell.c sqlite3.c -ldl -g ; echo "create table memos(text, priority INTEGER);" | ./a.out
Created attachment 21169 [details] sqlite sources
Created attachment 21170 [details] sqlite shell
-O1 -fipa-sra also leads to ICE.
IPA-SRA => Martin
Subject: Re: -fwhopr + ipa-sra misoptimize sqlite > IPA-SRA => Martin Well, the trick is that IPA-SRA is run before LTO streaming, so it means that it should not be affected by -fwhopr at all (and linking resulting .o file w/o LTO seems to work). So it is really combination of those.
reconfirmed.
still fails.
jh@evans:/abuild/jh/sqlite-3.6.23.1> /abuild/jh/trunk-install/bin/gcc -fPIC -O0 -flto=24 -fno-strict-aliasing -pthread -pipe -O2 shell.c sqlite3.c -ldl -g ; echo "create table memos(text, priority INTEGER);" | ./a.out jh@evans:/abuild/jh/sqlite-3.6.23.1> /abuild/jh/trunk-install/bin/gcc -fPIC -O0 -flto=24 -fno-strict-aliasing -pthread -pipe -O2 shell.c sqlite3.c -ldl -g -flto-partition=none ; echo "create table memos(text, priority INTEGER);" | ./a.out jh@evans:/abuild/jh/sqlite-3.6.23.1> /abuild/jh/trunk-install/bin/gcc -fPIC -O0 -flto=24 -fno-strict-aliasing -pthread -pipe -O2 shell.c sqlite3.c -ldl -g -flto-partition=1to1 ; echo "create table memos(text, priority INTEGER);" | ./a.out jh@evans:/abuild/jh/sqlite-3.6.23.1> So it seems solved now. I will try if mozilla now builds w/o lto-partition=none passed to C compiler.
Hmm, sadly we still get: /abuild/jh/trunk-install/bin/gcc -fPIC -O0 -flto=24 -fno-strict-aliasing -pthread -pipe -O2 shell.c sqlite3.c -ldl -g -flto-partition=1to1 -fno-use-linker-plugin ; echo "create table memos(text, priority INTEGER);" | ./a.out Segmentation fault (core dumped)
It also appears with lto-partition=none with profile feedback, so it is not WHOPR only bug.
In the Firefox case sqlite3.o gets compiled correctly, it is libmozsqlite3.so that segfaults when compiled with -flto and -fprofile-use : gcc -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -W -pedantic -Wno-long-long -march=native -fpermissive -fno-strict-aliasing -pthread -pipe -DNDEBUG -DTRIMMED -flto=4 -fwhole-program -fprofile-use -fprofile-correction -Wcoverage-mismatch -freorder-blocks-and-partition -O3 -fPIC -shared -Wl,-z,defs -Wl,-h,libmozsqlite3.so -o libmozsqlite3.so sqlite3.o -lpthread -Wl,-O1,--hash-style=gnu,--as-needed,--no-keep-memory -fprofile-use -Wl,-rpath-link,/var/tmp/mozilla-central/moz-build-dir/dist/bin -Wl,-rpath-link,/usr/lib -ldl This version runs fine (no -flto): gcc -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -W -pedantic -Wno-long-long -march=native -fpermissive -fno-strict-aliasing -pthread -pipe -DNDEBUG -DTRIMMED -Wcoverage-mismatch -freorder-blocks-and-partition -fwhole-program -fprofile-use -O3 -fPIC -shared -Wl,-z,defs -Wl,-h,libmozsqlite3.so -o libmozsqlite3.so sqlite3.o -lpthread -Wl,-O1,--hash-style=gnu,--as-needed,--no-keep-memory -Wl,-rpath-link,/var/tmp/mozilla-central/moz-build-dir/dist/bin -Wl,-rpath-link,/usr/lib -ldl And this one gives an internal compiler error (only -flto , no -fprofile-use): gcc -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -W -pedantic -Wno-long-long -march=native -fpermissive -fno-strict-aliasing -pthread -pipe -DNDEBUG -DTRIMMED -Wcoverage-mismatch -freorder-blocks-and-partition -flto -O3 -fPIC -shared -Wl,-z,defs -Wl,-h,libmozsqlite3.so -o libmozsqlite3.so sqlite3.o -lpthread -Wl,-O1,--hash-style=gnu,--as-needed,--no-keep-memory -Wl,-rpath-link,/var/tmp/mozilla-central/moz-build-dir/dist/bin -Wl,-rpath-link,/usr/lib -ldl lto1: internal compiler error: Floating point exception Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: /usr/x86_64-pc-linux-gnu/gcc-bin/4.6.0/gcc returned 1 exit status /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../x86_64-pc-linux-gnu/bin/ld: fatal error: lto-wrapper failed collect2: ld returned 1 exit status (All these commands should be run from: ./mozilla-central/moz-build-dir/db/sqlite3/src One can copy the resulting libmozsqlite3.so directly into /usr/lib/firefox-4.0b13pre and try to start Firefox, to check if it's OK or not)
> gcc -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -W -pedantic > -Wno-long-long -march=native -fpermissive -fno-strict-aliasing -pthread -pipe > -DNDEBUG -DTRIMMED -Wcoverage-mismatch -freorder-blocks-and-partition -flto -O3 > -fPIC -shared -Wl,-z,defs -Wl,-h,libmozsqlite3.so -o libmozsqlite3.so sqlite3.o > -lpthread -Wl,-O1,--hash-style=gnu,--as-needed,--no-keep-memory > -Wl,-rpath-link,/var/tmp/mozilla-central/moz-build-dir/dist/bin > -Wl,-rpath-link,/usr/lib -ldl > lto1: internal compiler error: Floating point exception This should be easy to fix. Having backtrace would save me from some burden trying to reproduce it ;) Honza
Here's what I got: (gdb) set follow-fork-mode child (gdb) run -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccZJwWXj.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -flto --eh-frame-hdr -m elf_x86_64 -shared -o libmozsqlite3.so /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../.. -z defs -h libmozsqlite3.so sqlite3.o -lpthread --hash-style=gnu -rpath-link /var/tmp/mozilla-central/moz-build-dir/dist/bin -rpath-link /usr/lib -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../lib64/crtn.o Starting program: /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/collect2 -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccZJwWXj.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -flto --eh-frame-hdr -m elf_x86_64 -shared -o libmozsqlite3.so /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../.. -z defs -h libmozsqlite3.so sqlite3.o -lpthread --hash-style=gnu -rpath-link /var/tmp/mozilla-central/moz-build-dir/dist/bin -rpath-link /usr/lib -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../lib64/crtn.o [New process 16093] process 16093 is executing new program: /usr/x86_64-pc-linux-gnu/binutils-bin/2.21.51.0.7/ld [New process 16102] process 16102 is executing new program: /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/lto-wrapper [New process 16103] process 16103 is executing new program: /usr/x86_64-pc-linux-gnu/gcc-bin/4.6.0/gcc [New process 16104] process 16104 is executing new program: /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/lto1 Program received signal SIGFPE, Arithmetic exception. [Switching to process 16104] 0x0000000000862ca7 in ?? () (gdb) bt #0 0x0000000000862ca7 in ?? () #1 0x000000000066f176 in execute_one_pass(opt_pass*) () #2 0x000000000066fa52 in execute_ipa_pass_list(opt_pass*) () #3 0x00000000004f284e in lto_main() () #4 0x00000000006fc247 in toplev_main(int, char**) () #5 0x00007ffff6d28f8d in __libc_start_main () from /lib/libc.so.6 #6 0x00000000004cd9f9 in _start () (gdb)
And the same with debugging symbols: Program received signal SIGFPE, Arithmetic exception. [Switching to process 5046] 0x000000000086d41c in cgraph_decide_recursive_inlining (new_edges=0x7fffffffd750, node=0x7ffff65dbb00) at ../../gcc/gcc/ipa-inline.c:906 906 if (curr->count * 100 / node->count < probability) (gdb) bt #0 0x000000000086d41c in cgraph_decide_recursive_inlining (new_edges=0x7fffffffd750, node=0x7ffff65dbb00) at ../../gcc/gcc/ipa-inline.c:906 #1 cgraph_decide_inlining_of_small_functions () at ../../gcc/gcc/ipa-inline.c:1193 #2 cgraph_decide_inlining () at ../../gcc/gcc/ipa-inline.c:1479 #3 0x00000000006571e9 in execute_one_pass (pass=0x102ee00) at ../../gcc/gcc/passes.c:1556 #4 0x000000000065787a in execute_ipa_pass_list (pass=0x102ee00) at ../../gcc/gcc/passes.c:1923 #5 0x00000000004c152f in do_whole_program_analysis () at ../../gcc/gcc/lto/lto.c:2350 #6 lto_main () at ../../gcc/gcc/lto/lto.c:2462 #7 0x00000000006e7510 in compile_file () at ../../gcc/gcc/toplev.c:579 #8 do_compile () at ../../gcc/gcc/toplev.c:1900 #9 toplev_main (argc=40, argv=0x11679c0) at ../../gcc/gcc/toplev.c:1963 #10 0x00007ffff6d28f8d in __libc_start_main () from /lib/libc.so.6 #11 0x00000000004a9979 in _start () at ../sysdeps/x86_64/elf/start.S:113 (gdb)
Sorry, forgot about the division by zero issue. Testing patch.
I'm getting a whole bunch of lto1: internal compiler error: Floating point exception using g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure -enable-gold=yes --enable-lto --with-fpmath=avx --with-build-config=bootstrap-lto --with-gmp-lib=/usr/local/lib64 --with-mpfr-lib=/usr/local/lib64 -with-mpc-lib=/usr/local/lib64 Thread model: posix gcc version 4.6.1 20110513 (prerelease) (GCC) before submitting a new bug report I would like to know if the patch by Honza quoted below is already in it or still pending
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44897 > > vincenzo Innocente <vincenzo.innocente at cern dot ch> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |vincenzo.innocente at cern > | |dot ch > > --- Comment #16 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-05-19 08:12:20 UTC --- > I'm getting a whole bunch of > lto1: internal compiler error: Floating point exception > using > g++ -v > Using built-in specs. > COLLECT_GCC=g++ > COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.6.1/lto-wrapper > Target: x86_64-unknown-linux-gnu > Configured with: ./configure -enable-gold=yes --enable-lto --with-fpmath=avx > --with-build-config=bootstrap-lto --with-gmp-lib=/usr/local/lib64 > --with-mpfr-lib=/usr/local/lib64 -with-mpc-lib=/usr/local/lib64 > Thread model: posix > gcc version 4.6.1 20110513 (prerelease) (GCC) > > before submitting a new bug report I would like to know if the patch by Honza > quoted below is already in it or still pending It is in mainline, I should backport it to 4.6.1. Will try to do it today or tomorrow. Honza > > -- > Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email > ------- You are receiving this mail because: ------- > You reported the bug.
Author: hubicka Date: Wed May 25 11:36:49 2011 New Revision: 174183 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174183 Log: PR tree-optimization/44897 * ipa-inline.c (cgraph_decide_recursive_inlining): Do not divide by zero for insane profiles. Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/ipa-inline.c
OK, division by 0 should be fixed both on mainline and 4.6 branch. I think the wrong code issue might be the corruption of jump tables, but will need to get past firewall to double check unless Martin beats me. It is his bug after all ;)
The problem as confirmed in Comment 9 no longer reproduce on mainline. So problem is either fixed or went latent. I am going to try 4.6.
(In reply to comment #20) > The problem as confirmed in Comment 9 no longer reproduce on mainline. So > problem is either fixed or went latent. I am going to try 4.6. Confirmed on mainline. With "-flto -fprofile-use" libmozsqlite3.so no longer segfaults. Must have been a recent change. It still segfaulted ~ a week ago.
Thanks for confirmation. My best bet is: 2011-05-29 Richard Guenther <rguenther@suse.de> PR tree-optimization/49217 * ipa-pure-const.c (propagate_pure_const): Fix typos. this bug could've caused symptoms seen here. Closing the PR then.