Created attachment 536724 [details] emerge --info (System 1) sys-devel/gcc-3.7.0 crashes with the error 'internal compiler error: Segmentation fault' when building some packages. This does not occur when building with sys-devel/gcc-6.4.0-r1. The crashes are not random and always occur in the same place when compiling these packages. I've tried compiling a few packages that I judge to be intensive builds such as glibc and the Linux kernel, but had no problems building those. gcc-3.7.0 is able to compile itself and only fails when the 'fortran' USE flag is enabled. I've tried compiling gcc-3.7.0 with all optimizations turned off and a good portion of USE flags turned off as well, but the crashes still occur. I'm uploading build logs for some of the packages that have failed. The crashes all occur when compiling similar functions that seem to involve string formatting.
Created attachment 536726 [details] sys-devel/gcc-3.7.0 build log
Created attachment 536728 [details] app-arch/tar-1.30 build log
Created attachment 536730 [details] app-emulation/dosemu-1.4.1_pre20130107 build log
Created attachment 536732 [details] www-apache/passenger-5.3.2 build log
I did remember to rebuild sys-devel/libtool after switching to sys-devel/gcc-7.3.0.
GCC 7.3.0 fails with segmentation fault on my laptop with Intel T2400 (32-bits) processor and 32-bits gentoo on libfortran with fortran use flag enabled
Created attachment 536874 [details] emerge --info (System 2)
Created attachment 536876 [details] lscpu (System 1)
Created attachment 536878 [details] lscpu (System 2)
I've found another 32-bit system with the same issue. I'm attaching emerge --info for the second system as well as lscpu output for both systems. It's the same packages failing in the same places. I tried compiling the failing files for a couple of the packages while running gcc under gdb and the backtraces come out the same. #0 0xb7eef989 in __gmpn_sqr_basecase () from /usr/lib/libgmp.so.10 #1 0xb7eef989 in __gmpn_sqr_basecase () from /usr/lib/libgmp.so.10 #2 0xffffffe5 in ?? () #3 0xb7f3a000 in ?? () from /usr/lib/libgmp.so.10 It looks like the issue is with libgmp. I've recompiled dev-libs/gmp with gcc-7.3.0, but the segfaults still occur.
Rebuilt dev-libs/gmp with debug info: 453 tmp-sqr_basecase.s: No such file or directory. (gdb) bt #0 0xb7ef04c9 in __gmpn_sqr_basecase () at tmp-sqr_basecase.s:453 #1 0xb7ef04c9 in __gmpn_sqr_basecase () at tmp-sqr_basecase.s:453 #2 0xffffffe5 in ?? () #3 0xb7f3a000 in ?? () from /usr/lib/libgmp.so.10
The issue seems to be with the 'pgo' USE flag and dev-libs/gmp. I've managed to fix it via the following procedure: 1. Disable the 'pgo' USE flag. 2. Switch the system compiler back to gcc-6.4.0. 3. Recompile '=sys-devel/gcc-6.4.0-r1' with 'pgo' disabled. 4. Recompile 'dev-libs/gmp' with 'pgo' disabled. 5. Recompile '=sys-devel/gcc-7.3.0' with 'pgo' disabled. 6. Switch the system compiler to gcc-7.3.0. At this point I was able to compile the failing packages successfully. Next I tried recompiling '=sys-devel/gcc-7.3.0' and 'dev-libs/gmp' with the 'pgo' USE flag enabled using gcc-7.3.0 as the system compiler. gcc began segfaulting again after this. After this I recompiled 'dev-libs/gmp' with 'pgo' disabled and I was able to compile the failing packages successfully again. It seems that gcc-7.3.0 segfaults on these 32-bit systems when 'dev-libs/gmp' is compiled with 'pgo' enabled, whether 'dev-libs/gmp' is compiled with gcc-6.4.0 or gcc-7.3.0.
If you still have a chance to preproduce it can you try to extract minimal example for it? https://wiki.gentoo.org/wiki/Gcc-ICE-reporting-guide
I've been running said systems with the 'pgo' USE flag turned off entirely. I was easily able to reproduce it again by compiling '=dev-libs/gmp-6.1.2' with the 'pgo' USE flag turned on with gcc-7.3. Afterwards attempting to compile '=app-arch/tar-1.31-r1' fails with an ICE. I didn't have any problems with GCC versions before 7.3. No other packages besides 'dev-libs/gmp' require 'pgo' enabled in order to reproduce. I will post the information requested in the reporting guide shortly.
To clarify 'sys-devel/gcc' doesn't have 'pgo' enabled, only 'dev-libs/gmp'.
ICE still occurs without the '-march=native' flag.
Created attachment 563016 [details] Temporary source file ICE occurs when building 'app-arch/tar' at the following point: i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -O2 -pipe -c -o human.o human.c human.c: In function ‘human_readable’: human.c:153:1: internal compiler error: Segmentation fault human_readable (uintmax_t n, char *buf, int opts, ^~~~~~~~~~~~~~
Created attachment 563018 [details] -march=native options
I was able to reproduce with all gcc versions available on Gentoo and with a build from the gcc git repository HEAD as well.
# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/7.3.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-7.3.0-r3/work/gcc-7.3.0/configure --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/7.3.0 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/7.3.0/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/7.3.0 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/7.3.0/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/7.3.0/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/7.3.0/include/g++-v7 --with-python-dir=/share/gcc-data/i686-pc-linux-gnu/7.3.0/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=yes --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 7.3.0-r3 p1.4' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --with-arch=i686 --enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --disable-libmpx --enable-vtable-verify --enable-libvtv --disable-libquadmath --enable-lto --without-isl --enable-libsanitizer --enable-default-pie --enable-default-ssp Thread model: posix gcc version 7.3.0 (Gentoo 7.3.0-r3 p1.4)
Backtrace just before the crash. It occurs in __gmpn_sqr_basecase(). #0 0xb7edf160 in __gmpn_sqr_basecase () from /usr/lib/libgmp.so.10 #1 0xb7efe135 in __gmpn_toom3_sqr () from /usr/lib/libgmp.so.10 #2 0xb7edec13 in __gmpn_sqr () from /usr/lib/libgmp.so.10 #3 0xb7ee488b in __gmpn_get_str () from /usr/lib/libgmp.so.10 #4 0xb7f3a83f in mpfr_get_str_aux (str=str@entry=0x9c764c0 "", exp=exp@entry=0xbfffe3f8, r=r@entry=0xbfffdb00, n=513, f=-28, e=-1, b=10, m=4933, rnd=MPFR_RNDD) at /usr/src/debug/dev-libs/mpfr-3.1.6/mpfr-3.1.6/src/get_str.c:150 #5 0xb7f3ae72 in mpfr_get_str (s=0x9c764c0 "", e=0xbfffe3f8, b=10, m=<optimized out>, x=0xbfffe684, rnd=MPFR_RNDD) at /usr/src/debug/dev-libs/mpfr-3.1.6/mpfr-3.1.6/src/get_str.c:2518 #6 0xb7f401f7 in regular_fg (np=np@entry=0xbfffe500, p=p@entry=0xbfffe684, spec=..., dec_info=0x0) at /usr/src/debug/dev-libs/mpfr-3.1.6/mpfr-3.1.6/src/vasprintf.c:1376 #7 0xb7f41a32 in partition_number (spec=..., p=<optimized out>, np=0xbfffe500) at /usr/src/debug/dev-libs/mpfr-3.1.6/mpfr-3.1.6/src/vasprintf.c:1600 #8 sprnt_fp (spec=..., p=<optimized out>, buf=0xbfffe4ac) at /usr/src/debug/dev-libs/mpfr-3.1.6/mpfr-3.1.6/src/vasprintf.c:1710 #9 __gmpfr_vasprintf (ptr=<optimized out>, fmt=0xbfffe60a "", ap=0xbfffe5d4 "\345\254\016\t") at /usr/src/debug/dev-libs/mpfr-3.1.6/mpfr-3.1.6/src/vasprintf.c:2033 #10 0xb7f3f47c in mpfr_snprintf (buf=0x0, size=0, fmt=0xbfffe604 "%.*RDf") at /usr/src/debug/dev-libs/mpfr-3.1.6/mpfr-3.1.6/src/printf.c:168 #11 0x08ec5681 in (anonymous namespace)::get_mpfr_format_length (x=x@entry=0xbfffe684, flags=flags@entry=0x90eace5 "", prec=<optimized out>, spec=<optimized out>, rndspec=68 'D') at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:1472 #12 0x08ec582a in (anonymous namespace)::format_floating_max (type=<optimized out>, spec=spec@entry=102 'f', prec=0) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:1514 #13 0x08ec9e63 in (anonymous namespace)::format_floating (prec=0xbfffe740, dir=...) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:1634 #14 (anonymous namespace)::format_floating (dir=..., arg=0x0) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:1782 #15 0x08ec82ba in (anonymous namespace)::format_directive (info=..., res=res@entry=0xbfffe928, dir=...) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:2594 #16 0x08ecb4b7 in (anonymous namespace)::pass_sprintf_length::compute_format_length (this=0xb788b054, res=0xbfffe928, info=...) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:3264 #17 (anonymous namespace)::pass_sprintf_length::handle_gimple_call (gsi=gsi@entry=0xbfffeb30, this=0x9beac50) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:3693 #18 0x08eccc77 in (anonymous namespace)::pass_sprintf_length::execute (this=0x9beac50, fun=0xb788c000) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/gimple-ssa-sprintf.c:3721 #19 0x0869988b in execute_one_pass (pass=<optimized out>) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/passes.c:2465 #20 0x0869a15f in execute_pass_list_1 (pass=0x9beac50, pass@entry=0x9be8f30) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/passes.c:2554 #21 0x0869a1b9 in execute_pass_list (fn=0xb788c000, pass=0x9be8f30) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/passes.c:2565 #22 0x0835e73d in cgraph_node::analyze (this=0xb788f000) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/cgraphunit.c:668 #23 0x08361712 in analyze_functions (first_time=first_time@entry=true) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/cgraphunit.c:1118 #24 0x083629d3 in symbol_table::finalize_compilation_unit (this=0xb77fb0c4) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/cgraphunit.c:2604 #25 0x0877a84e in compile_file () at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/toplev.c:492 #26 0x081bf62f in do_compile () at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/toplev.c:2003 #27 toplev::main (this=0xbfffed8a, argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/toplev.c:2138 #28 0x081c185c in main (argc=12, argv=0xbfffee54) at /usr/src/debug/sys-devel/gcc-7.3.0-r3/gcc-7.3.0/gcc/main.c:39
Created attachment 563462 [details] Temporary source file (reduced)
This is the system I've been working with over these recent comments. Architecture: i686 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 36 bits physical, 48 bits virtual CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 15 Model name: Intel(R) Xeon(R) CPU 5140 @ 2.33GHz Stepping: 6 CPU MHz: 2333.543 BogoMIPS: 4667.08 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 4096K Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca lahf_lm tpr_shadow dtherm
The gdb backtrace was produced with the following command: i686-pc-linux-gnu-gcc -c -o human.o human.i
Your testcase from #22 is saved as human.i then? Is it C or fortran? I may be able to check it with arm and amd64.
It's C. It's actually a preprocessed and reduced copy of 'gnu/human.c' from the tar package. I haven't been able to reproduce this on amd64, although I believe I've been able to reproduce it on all my hardware systems configured as x86. I wasn't able to reproduce it on an x86 VirtualBox image running on an amd64 system though. Haven't tried arm.
Is it legit to use a preprocessed source with amd64 or arm processor? here is my output, if legit: LANG=C /usr/x86_64-pc-linux-gnu/gcc-bin/7.3.0/gcc -c -o human.o human.i human.i:1:1: warning: return type defaults to 'int' [-Wimplicit-int] a() { sprintf(a, "%.0Lf"); } ^ human.i: In function 'a': human.i:1:7: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration] a() { sprintf(a, "%.0Lf"); } ^~~~~~~ human.i:1:7: warning: incompatible implicit declaration of built-in function 'sprintf' human.i:1:7: note: include '<stdio.h>' or provide a declaration of 'sprintf' human.i:1:15: warning: passing argument 1 of 'sprintf' from incompatible pointer type [-Wincompatible-pointer-types] a() { sprintf(a, "%.0Lf"); } ^ human.i:1:15: note: expected 'char *' but argument is of type 'int (*)()' human.i:1:23: warning: format '%Lf' expects a matching 'long double' argument [-Wformat=] a() { sprintf(a, "%.0Lf"); } only warnings, no segfault, dmesg clean as well.
What's left in the reduced file looks like pretty generic C, so I think it should reproduce the issue on whatever architectures are effected. So far it only seems to be x86. Also, it doesn't appear that 'sys-devel/gcc[pgo]' is the problem. The crashes only seem to occur when 'dev-libs/gmp' is built with the 'pgo' USE flag. I wonder if the title should be changed to reflect that?
(In reply to Robert Gill from comment #28) > What's left in the reduced file looks like pretty generic C, so I think it > should reproduce the issue on whatever architectures are effected. So far it > only seems to be x86. Also, it doesn't appear that 'sys-devel/gcc[pgo]' is > the problem. The crashes only seem to occur when 'dev-libs/gmp' is built > with the 'pgo' USE flag. I wonder if the title should be changed to reflect > that? That's a lot of great debugging in this thread! Can you also share successful build log of gmp[pgo] package? For me training part fails due to #650558. I suspect I don't get broken gmp due to it. I hope to extract numbers generated at traning on your machine from logs and apply them locally.
Created attachment 563698 [details] =dev-libs/gmp[pgo] build.log
I was also snooping around the work directory looking for the profiling data (*.gcda files are what I'm aware of) but wasn't able to find anything. In fact the 'tuneup' executable and all of it's source files seem to get deleted sometime during the build process. The only file remaining after the build completes is 'gmp-6.1.2-abi_x86_32.x86/tune/sqr_basecase.c' which appears to be an auto-generated stub file.
Thank you! With your tuneup.c-generated data I can crash gmp locally as well. I guess you can also see that optimised gmp fail it's own test suite: FEATURES=test USE=pgo emerge -v1 =sys-libs/gmp-6.1.2
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=480424f2bb7d3d555e5ccefba71a1f5f166bae20 commit 480424f2bb7d3d555e5ccefba71a1f5f166bae20 Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2019-02-05 21:37:04 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2019-02-05 21:37:30 +0000 dev-libs/gmp: allow user patches To ease tweaking 'tuneup' and other tools allow user patches. Bug: https://bugs.gentoo.org/658688 Package-Manager: Portage-2.3.59, Repoman-2.3.12 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> dev-libs/gmp/gmp-6.1.2.ebuild | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de85d6ef4ae9f32550c0fa2090a135d63bc757f3 commit de85d6ef4ae9f32550c0fa2090a135d63bc757f3 Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2019-02-05 22:18:53 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2019-02-05 22:19:04 +0000 dev-libs/gmp: drop USE=pgo from stable ebuild, bug #658688 USE=pgo generates optimal constants when running 'tuneup' benchmark locally. If benchmark does not succeed default parameters are used. Else benchmark's output is used to tune gmp behaviour. Unfortunately at least on x86 some primitives like __mpn_sqr_basecase generate invalid assembly code at fail tests. In bug #650558 we found out that 'tuneup' is not very well maintained upstream. Let's dropp support for USE=pgo until it gets better. Reported-by: Robert Gill Closes: https://bugs.gentoo.org/658688 Bug: https://bugs.gentoo.org/650558 Package-Manager: Portage-2.3.59, Repoman-2.3.12 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> dev-libs/gmp/gmp-6.1.2.ebuild | 13 +------------ dev-libs/gmp/metadata.xml | 1 - 2 files changed, 1 insertion(+), 13 deletions(-)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d89510821e84ece8bf057f57f297016fae114e06 commit d89510821e84ece8bf057f57f297016fae114e06 Author: Sam James <sam@gentoo.org> AuthorDate: 2023-07-30 17:01:19 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-07-30 17:01:19 +0000 dev-libs/gmp: add comment wrt no pgo Bug: https://bugs.gentoo.org/454912 Bug: https://bugs.gentoo.org/650558 Bug: https://bugs.gentoo.org/658688 Signed-off-by: Sam James <sam@gentoo.org> dev-libs/gmp/gmp-6.3.0.ebuild | 4 ++++ 1 file changed, 4 insertions(+)