Bug 105561 - Nondeterministic ICE on creation of bits/stdc++.h.gch/O2g.gch and bits/extc++.h.gch/O2g.gch
Summary: Nondeterministic ICE on creation of bits/stdc++.h.gch/O2g.gch and bits/extc++...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: pch (show other bugs)
Version: 12.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2022-05-11 10:47 UTC by Sascha Wilde
Modified: 2022-10-27 06:35 UTC (History)
0 users

See Also:
Host: i386-unknown-netbsdelf9.2
Target: i386-unknown-netbsdelf9.2
Build: i386-unknown-netbsdelf9.2
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sascha Wilde 2022-05-11 10:47:41 UTC
I'm experiencing a strange, not deterministic ISE on creation of
bits/extc++.h.gch/O2g.gch and bits/stdc++.h.gch/O2g.gch during building
of gcc 12.1 on i386 NetBSD 9.2.

I know the following sounds like an hardware problem, but it certainly
is not, as it can be observed in the exactly same way on to totally
different hardwares:

1. A native system running NetBSD 9.2 (i386):
   Intel(R) Atom(TM) CPU N270   @ 1.60GHz
   2 GiB RAM

2. A virtual system running NetBSD 9.2 (i386):
   VirtualBox guest with
   11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
   16 GiB RAM (for the guest)

The symptoms are identical on both.

It happens during bootstraps well as during non boostrap compilation
with an already compiled gcc 12.1.

My configuration Options are:

../gcc-12.1.0/configure \
  --with-bugurl=https://github.com/jashandeep-sohi/libgccjit-pkg/issues \
  --enable-shared --enable-host-shared --enable-checking=release \
  --enable-languages=jit --disable-multilib --disable-libssp \
  --disable-lto --disable-libquadmath --disable-liboffloadmic \
  --disable-libada --disable-libsanitizer \
  --disable-libquadmath-support --disable-libgomp --disable-libvtv \
  --disable-libsanitizer --with-gmp=/usr/local --with-mpc=/usr/local \
  --with-mpfr=/usr/local 

Here is what happens (I'll choose bits/extc++.h.gch/O2g.gch as an
example, the exact same thing happens for bits/stdc++.h.gch/O2g.gch,
too):

The compilation fails like this:

8< ----------------------------------------------------------------------
[...]
/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc/xgcc -shared-libgcc -B/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc -nostdinc++ -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src/.libs -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/libsupc++/.libs -B/usr/local/i386-unknown-netbsdelf9.2/bin/ -B/usr/local/i386-unknown-netbsdelf9.2/lib/ -isystem /usr/local/i386-unknown-netbsdelf9.2/include -isystem /usr/local/i386-unknown-netbsdelf9.2/sys-include   -fno-checking -x c++-header -nostdinc++ -g -O2  -I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2 -I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include -I/home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++  -O2 -g /home/wilde/src/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h -o i386-unknown-netbsdelf9.2/bits/extc++.h.gch/O2g.gch                                                     
xgcc: internal compiler error: Segmentation fault signal terminated program cc1plus
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <https://github.com/jashandeep-sohi/libgccjit-pkg/issues> for instructions.
gmake[5]: *** [Makefile:1904: i386-unknown-netbsdelf9.2/bits/extc++.h.gch/O2g.gch] Error 4
gmake[5]: Leaving directory '/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include'
gmake[4]: *** [Makefile:576: all-recursive] Error 1
gmake[4]: Leaving directory '/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3'
gmake[3]: *** [Makefile:501: all] Error 2
gmake[3]: Leaving directory '/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3'
gmake[2]: *** [Makefile:17355: all-stage1-target-libstdc++-v3] Error 2
gmake[2]: Leaving directory '/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build'
gmake[1]: *** [Makefile:22332: stage1-bubble] Error 2
gmake[1]: Leaving directory '/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build'
gmake: *** [Makefile:1067: all] Error 2
-------------------------------------------------------------------------

Then I try to compile the file by hand, which usually fails, too some
times, but eventually succeeds:

8< ----------------------------------------------------------------------
% cd ~/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include
% /home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc/xgcc -shared-libgcc -B/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc -nostdinc++ -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src/.libs -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/libsupc++/.libs -B/usr/local/i386-unknown-netbsdelf9.2/bin/ -B/usr/local/i386-unknown-netbsdelf9.2/lib/ -isystem /usr/local/i386-unknown-netbsdelf9.2/include -isystem /usr/local/i386-unknown-netbsdelf9.2/sys-include   -fno-checking -x c++-header -nostdinc++ -g -O2  -I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2 -I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include -I/home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++  -O2 -g /home/wilde/src/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h -o i386-unknown-netbsdelf9.2/bits/extc++.h.gch/O2g.gch
xgcc: internal compiler error: Bus error signal terminated program cc1plus
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <https://github.com/jashandeep-sohi/libgccjit-pkg/issues> for instructions.
% /home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc/xgcc -shared-libgcc -B/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc -nostdinc++ -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src/.libs -L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/libsupc++/.libs -B/usr/local/i386-unknown-netbsdelf9.2/bin/ -B/usr/local/i386-unknown-netbsdelf9.2/lib/ -isystem /usr/local/i386-unknown-netbsdelf9.2/include -isystem /usr/local/i386-unknown-netbsdelf9.2/sys-include   -fno-checking -x c++-header -nostdinc++ -g -O2  -I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2 -I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include -I/home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++  -O2 -g /home/wilde/src/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h -o i386-unknown-netbsdelf9.2/bits/extc++.h.gch/O2g.gch                                                  
# No error this time
-------------------------------------------------------------------------

There are even variations in the error like:

8< ----------------------------------------------------------------------
In file included from /home/wilde/src/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h:82:
/home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/ext/enc_filebuf.h:63:1: internal compiler error: Segmentation fault
   63 | } // namespace
      | ^
0x8f0b06d crash_signal
        ../../gcc-12.1.0/gcc/toplev.cc:322
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://github.com/jashandeep-sohi/libgccjit-pkg/issues> for instructions.
------------------------------------------------------------------------

After doing this exercise for the two header files the compilation can
be restarted using gmake and finishes as expected...

The problem only ever arises with this two files, but for those I
experienced it every time I build gcc 12.1 on NetBSD 9.2.

I'm fully aware, that this looks like an hardware problem, but it
really happens independently of the hardware used.
Comment 1 Richard Biener 2022-05-11 11:05:17 UTC
I wonder if you can get a backtrace from gdb for the crash?  When you add -v
to the failing command you should see cc1plus being invoked, trace on that
command.

Does NetBSD have address space randomization?  That might influence whether the bug reproduces or not.
Comment 2 Sascha Wilde 2022-05-11 12:38:16 UTC
(In reply to Richard Biener from comment #1)
> I wonder if you can get a backtrace from gdb for the crash?  When you add -v
> to the failing command you should see cc1plus being invoked, trace on that
> command.
> 
> Does NetBSD have address space randomization?  That might influence whether
> the bug reproduces or not.

Yes NetBSD 9.2 has address space layout randomization active.

By "trace" you mean running the cc1plus command in gdb?
Comment 3 Sascha Wilde 2022-05-11 13:02:49 UTC
(In reply to Richard Biener from comment #1)
> I wonder if you can get a backtrace from gdb for the crash?  When you add -v
> to the failing command you should see cc1plus being invoked, trace on that
> command.

Reading symbols from /home/wilde/src/gcc-12.1.0-build/./gcc/cc1plus...
run(gdb) run
Starting program: /home/wilde/src/gcc-12.1.0-build/gcc/cc1plus -quiet -nostdinc++ -nostdinc++ -v -I /home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2 -I /home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include -I /home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++ -iprefix /home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/ -isystem /home/wilde/src/gcc-12.1.0-build/./gcc/include -isystem /home/wilde/src/gcc-12.1.0-build/./gcc/include-fixed -isystem /usr/local/i386-unknown-netbsdelf9.2/include -isystem /usr/local/i386-unknown-netbsdelf9.2/sys-include /home/wilde/src/gcc-12.1.0/libstdc++-v3/include/precompiled/stdc++.h -quiet -dumpdir i386-unknown-netbsdelf9.2/bits/stdc++.h.gch/O2g.gch- -dumpbase stdc++.h -dumpbase-ext .h -mtune=generic -march=i486 -g -g -O2 -O2 -version -fchecking=1 -o /tmp//cccDHD3H.s --output-pch= i386-unknown-netbsdelf9.2/bits/stdc++.h.gch/O2g.gch
GNU C++17 (GCC) version 12.1.0 (i386-unknown-netbsdelf9.2)
        compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/i386-unknown-netbsdelf9.2/include"
ignoring nonexistent directory "/usr/local/i386-unknown-netbsdelf9.2/sys-include"
ignoring nonexistent directory "/home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include"
ignoring nonexistent directory "/home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include-fixed"
ignoring nonexistent directory "/home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/../../../../i386-unknown-netbsdelf9.2/include"
ignoring nonexistent directory "/usr/local/lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/local/lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include-fixed"
ignoring nonexistent directory "/usr/local/i386-unknown-netbsdelf9.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2
 /home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include
 /home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++
 /home/wilde/src/gcc-12.1.0-build/./gcc/include
 /home/wilde/src/gcc-12.1.0-build/./gcc/include-fixed
 /usr/include
End of search list.
GNU C++17 (GCC) version 12.1.0 (i386-unknown-netbsdelf9.2)
        compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a1413fe37641e0518146e5d1b732cd59

Program received signal SIGBUS, Bus error.
0xb0cb4957 in __mmap () from /usr/lib/libc.so.12
(gdb) bt
#0  0xb0cb4957 in __mmap () from /usr/lib/libc.so.12
#1  0xb0cb1823 in mmap () from /usr/lib/libc.so.12
#2  0x08d7881d in netbsd_gt_pch_get_address (size=<optimized out>, fd=<optimized out>) at ../../gcc-12.1.0/gcc/config/host-netbsd.cc:53
#3  0x086baf8d in gt_pch_save (f=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>) at ../../gcc-12.1.0/gcc/ggc-common.cc:529
#4  0x084d3030 in c_common_write_pch () at ../../gcc-12.1.0/gcc/c-family/c-pch.cc:175
#5  0x0832258d in c_parse_final_cleanups () at ../../gcc-12.1.0/gcc/cp/decl2.cc:5075
#6  0x084d2bf1 in c_common_parse_file () at ../../gcc-12.1.0/gcc/c-family/c-opts.cc:1262
#7  0x089bbc3e in compile_file () at ../../gcc-12.1.0/gcc/toplev.cc:452
#8  0x09a1fbf5 in do_compile (no_backend=<optimized out>) at ../../gcc-12.1.0/gcc/toplev.cc:2168
#9  toplev::main (this=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>, argc=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>, argv=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>)
    at ../../gcc-12.1.0/gcc/toplev.cc:2320
#10 0x09a21b12 in main (argc=41, argv=0xbfb86ad0) at ../../gcc-12.1.0/gcc/main.cc:39
(gdb)