https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114381
Bug ID: 114381
Summary: (Sporadic) crash generating
x86_64-pc-cygwin/bits/extc++.h.gch/O2g.gch
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: pch
Assignee: unassigned at gcc dot gnu.org
Reporter: roland.mainz at nrubsig dot org
Target Milestone: ---
Building gcc from scratch crashes generating
x86_64-pc-cygwin/bits/extc++.h.gch/O2g.gch.
Note while the crash happens on Cygwin it looks like a *generic* memory
corruption issue.
**** Versions:
$ gcc --version
gcc (GCC) 11.4.0
$ uname -a
CYGWIN_NT-10.0-19045 wingrendel02 3.5.1-1.x86_64 2024-02-27 11:54 UTC x86_64
Cygwin
**** Steps to reproduce:
- Note that this happens only SPORADICALLY
- Cygwin is NOT Windows, Cygwin is a POSIX layer on top of Win32 and has it's
own memory allocator, which works more like Linux/UNIX than Win32. So the IRC
comments about memory layout vs. Windows should be taken with a grain/mountain
of salt
- Compile with:
# crash happens with "releases/gcc-13.1.0" and "releases/gcc-13.2.0"!
$ git clone -b releases/gcc-13.1.0 --single-branch ../gcc.bundle
$ cd gcc
$ configure
$ yes | make -j8 all
Log output:
---- snip ----
/cygdrive/m/builds/gcc20240317_50m/gcc/host-x86_64-pc-cygwin/gcc/xgcc
-shared-libgcc
-B/cygdrive/m/builds/gcc20240317_50m/gcc/host-x86_64-pc-cygwin/gcc -nostdinc++
-L/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/src
-L/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/src/.libs
-L/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/libsupc++/.libs
-B/usr/local/x86_64-pc-cygwin/bin/ -B/usr/local/x86_64-pc-cygwin/lib/ -isystem
/usr/local/x86_64-pc-cygwin/include -isystem
/usr/local/x86_64-pc-cygwin/sys-include -fno-checking -x c++-header
-nostdinc++ -g -O2
-I/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/include/x86_64-pc-cygwin
-I/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/include
-I/cygdrive/m/builds/gcc20240317_50m/gcc/libstdc++-v3/libsupc++ -O2 -g
/cygdrive/m/builds/gcc20240317_50m/gcc/libstdc++-v3/include/precompiled/stdtr1c++.h
-o x86_64-pc-cygwin/bits/stdtr1c++.h.gch/O2g.gch
mkdir -p ./x86_64-pc-cygwin/bits/extc++.h.gch
/cygdrive/m/builds/gcc20240317_50m/gcc/host-x86_64-pc-cygwin/gcc/xgcc
-shared-libgcc
-B/cygdrive/m/builds/gcc20240317_50m/gcc/host-x86_64-pc-cygwin/gcc -nostdinc++
-L/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/src
-L/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/src/.libs
-L/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/libsupc++/.libs
-B/usr/local/x86_64-pc-cygwin/bin/ -B/usr/local/x86_64-pc-cygwin/lib/ -isystem
/usr/local/x86_64-pc-cygwin/include -isystem
/usr/local/x86_64-pc-cygwin/sys-include -fno-checking -x c++-header
-nostdinc++ -g -O2
-I/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/include/x86_64-pc-cygwin
-I/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/include
-I/cygdrive/m/builds/gcc20240317_50m/gcc/libstdc++-v3/libsupc++ -O2 -g
/cygdrive/m/builds/gcc20240317_50m/gcc/libstdc++-v3/include/precompiled/extc++.h
-o x86_64-pc-cygwin/bits/extc++.h.gch/O2g.gch
*** starting 'dumper
"M:/builds/gcc20240317_50m/gcc/host-x86_64-pc-cygwin/gcc/cc1plus.exe" 8244' for
pid 0, tid 1164
make[5]: *** [Makefile:1938: x86_64-pc-cygwin/bits/extc++.h.gch/O2g.gch] Error
1
make[5]: Leaving directory
'/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/include'
make[4]: *** [Makefile:576: all-recursive] Error 1
make[4]: Leaving directory
'/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3'
make[3]: *** [Makefile:501: all] Error 2
make[3]: Leaving directory
'/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3'
make[2]: *** [Makefile:18286: all-stage1-target-libstdc++-v3] Error 2
make[2]: Leaving directory '/cygdrive/m/builds/gcc20240317_50m/gcc'
make[1]: *** [Makefile:25094: stage1-bubble] Error 2
make[1]: Leaving directory '/cygdrive/m/builds/gcc20240317_50m/gcc'
make: *** [Makefile:1080: all] Error 2
---- snip ----
Stack trace:
---- snip ----
roland_mainz@wingrendel02
/cygdrive/m/builds/gcc20240317_50m/gcc/x86_64-pc-cygwin/libstdc++-v3/include
$ gdb ../../../host-x86_64-pc-cygwin/gcc/cc1plus.exe cc1plus.exe.core
GNU gdb (GDB) (Cygwin 13.2-1) 13.2
[snip]
[New Thread 0x48c]
[New Thread 0x18c4]
[New Thread 0x1370]
#0 0x00007ffaa106d664 in ntdll!ZwDelayExecution () from
C:/Windows/SYSTEM32/ntdll.dll
[Current thread is 1 (Thread 0x48c)]
(gdb) bt
#0 0x00007ffaa106d664 in ntdll!ZwDelayExecution () from
C:/Windows/SYSTEM32/ntdll.dll
#1 0x00007ffa9ec9b62e in SleepEx () from C:/Windows/System32/KERNELBASE.dll
#2 0x00007ffa9429e567 in secure_getenv () from C:/cygwin64/bin/cygwin1.dll
#3 0x00007ffa942a01cc in secure_getenv () from C:/cygwin64/bin/cygwin1.dll
#4 0x00007ffaa10723af in ntdll!.chkstk () from C:/Windows/SYSTEM32/ntdll.dll
#5 0x00007ffaa10214b4 in ntdll!RtlRaiseException () from
C:/Windows/SYSTEM32/ntdll.dll
#6 0x00007ffaa1070ebe in ntdll!KiUserExceptionDispatcher () from
C:/Windows/SYSTEM32/ntdll.dll
#7 0x0000000100cba6ce in gt_pch_p_13string_concat (this_obj=0x6ffffd85ccb8,
x_p=0x6ffff7b4ebe0, op=0x100be765e <relocate_ptrs(void*, void*, void*)>,
cookie=0x7ffffc7a0) at gtype-desc.cc:8199
#8 0x0000000100be801c in gt_pch_save (f=0xa000b5060) at
../.././gcc/ggc-common.cc:641
#9 0x000000010092e332 in c_common_write_pch () at
../.././gcc/c-family/c-pch.cc:175
#10 0x00000001005846da in c_parse_final_cleanups () at
../.././gcc/cp/decl2.cc:4935
#11 0x000000010092ca4d in c_common_parse_file () at
../.././gcc/c-family/c-opts.cc:1266
#12 0x000000010102e259 in compile_file () at ../.././gcc/toplev.cc:444
#13 0x0000000101031ba0 in do_compile (no_backend=false) at
../.././gcc/toplev.cc:2125
#14 0x0000000101031ffb in toplev::main (this=0x7ffffcc2a, argc=44,
argv=0xa00020b70) at ../.././gcc/toplev.cc:2277
#15 0x00000001027d2164 in main (argc=44, argv=0xa00020b70) at
../.././gcc/main.cc:39
---- snip ----
IRC debate, including workaround:
---- snip ----
11:20:48 jakub | nrubsig: bugs should be reported to bugzilla, not here; I'm
afraid I have hundreds of bugs to look at for targets I care about, so unless
you can reproduce
| it on other targets, it will have to be somebody who cares
about Windows to analyze it
11:22:39 <-- | mcdarienzo ([email protected]) has quit
(Ping timeout: 480 seconds)
11:24:43 d0ggie | pch is broken on windows as allocation using the fixed
address might not succeed in general and there is fixed retry loop using delay
that kills all
| performance benefits
11:26:55 nrubsig | d0ggie: OUCH. Where is that documented ?
11:27:13 jwakely | it probably isn't
11:27:54 jwakely | but maybe --disable-libstdcxx-pch should be the default on
Windows
11:28:42 jwakely | (and maybe everywhere else too ;-)
11:28:45 d0ggie | hmm.. actually, cygwin mght not use win32 code so then the
next best thing is to update cygwin and disable aslr et. al.
11:28:49 sam_ | jwakely++
11:31:06 --> | mcdarienzo ([email protected]) has
joined #gcc
11:31:52 jakub | note, since a few years PCH does support relocation (meant
e.g. for Linux PIE support), but it needs extra target support which likely
isn't done for Windows
11:33:28 d0ggie | but if you want to look at it, the related cygwin emulation
code might look a bit cryptic but it is not spread across the entire project
but a few files
---- snip ----