From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2ABD13858C2F; Wed, 17 May 2023 11:10:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2ABD13858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684321818; bh=I8EcWwn4/chR+l0t6AA/rCUvqugus4wDdZLI7ABlJ6E=; h=From:To:Subject:Date:From; b=XAc7mbZcolqNpQg8iKfmWNt55hgmU4s/9nIcdLz3zBtW+e3vwx42SLqJFt/0tWX17 HYHRsqUbS5O6KYwx1VQqXiiqsOHg0xUMlq9JJHUuSviBMMEfbQ3WbxALKv6NHQZEnq sF/MZZ4tONgdW/ITBR/pmhlgCXEBFlBTDnmzDghk= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109889] New: [13/14 Regression] Segfault in __run_exit_handlers since r13-5309-gc3c6c307792026 Date: Wed, 17 May 2023 11:10:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone cf_gcctarget attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109889 Bug ID: 109889 Summary: [13/14 Regression] Segfault in __run_exit_handlers since r13-5309-gc3c6c307792026 Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- Target: powerpc64le-unknown-linux-gnu Created attachment 55099 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55099&action=3Dedit Gzipped preprocessed source I'm seeing test failures on powerpc64le when using -D_GLIBCXX_DEBUG, which started with r13-5309-gc3c6c307792026. I don't see anything wrong with that library change, so if I'm not missing something silly, then it might be a latent compiler bug that was revealed by reducing the amount of code run in= the library. The attached preprocessed source crashes when built with -O2 -ffunction-sections -Wl,--gc-sections It runs OK with -fno-lifetime-dse or with -fsanitize=3Dundefined or if eith= er of -ffunction-sections or -Wl,--gc-sections is removed. At the crash GDB shows: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff765b7cc in __run_exit_handlers (status=3D,=20 listp=3D0x7ffff7860ad0 <__exit_funcs>,=20 run_list_atexit=3Drun_list_atexit@entry=3Dtrue,=20 run_dtors=3Drun_dtors@entry=3Dtrue) at exit.c:62 62 __exit_funcs_done =3D true;=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =E2=94=80=E2=94=80=E2=94=80 Assembly =E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80 0x00007ffff765b7b8 __run_exit_handlers+600 std r9,0(r24) 0x00007ffff765b7bc __run_exit_handlers+604 bne 0x7ffff765b8d8 <__run_exit_handlers+888> 0x00007ffff765b7c0 __run_exit_handlers+608 li r10,1 0x00007ffff765b7c4 __run_exit_handlers+612 nop 0x00007ffff765b7c8 __run_exit_handlers+616 li r9,0 0x00007ffff765b7cc __run_exit_handlers+620 stb r10,-18040(r2) 0x00007ffff765b7d0 __run_exit_handlers+624 lwsync 0x00007ffff765b7d4 __run_exit_handlers+628 lwarx r10,0,r31 0x00007ffff765b7d8 __run_exit_handlers+632 stwcx. r9,0,r31 0x00007ffff765b7dc __run_exit_handlers+636 bne- 0x7ffff765b7d4 <__run_exit_handlers+628> =E2=94=80=E2=94=80=E2=94=80 Registers =E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80 r0 0x00007ffff765b700 r1 0x00007fffffffe8b0 r2 0x0000000000000000 r3 0x0000000000000000 r4 0x0000000000000000 r5 0x0000000000000000 r6 0x0000000000000000 r7 0x0000000000000000 r8 0x0000000000000000 r9 0x0000000000000000 r10 0x0000000000000001 r11 0x0000000000002000 r12 0x00007ffff7a30960 r13 0x00007ffff7ffc320 r14 0x0000000000000000 r15 0x0000000000000000 r16 0x0000000000000000 r17 0x0000000000000000 r18 0x0000000000000000 r19 0x0000000000000000 r20 0x0000000000000000 r21 0x0000000000000000 r22 0x0000000000000000 r23 0x0000000000000001 r24 0x00007ffff7860ad0 r25 0x0000000000000000 r26 0x0000000000000000 r27 0x00007ffff7862468 r28 0x0000000000000001 r29 0x0000000000000000 r30 0x00007ffff7862458 r31 0x00007ffff7862868 pc 0x00007ffff765b7cc msr 0x900000000000d033 cr 0x24002422 lr 0x00007ffff765b700 ctr 0x0000000000000000 xer 0x000000dd=20=20=20=20= =20=20=20=20 fpscr 0x0000000000000000 vscr 0x00000000=20=20=20=20= =20=20=20=20 vrsave 0xffffffff ppr 0x000c000000000000 dscr 0x0000000000000010 tar 0x0000000000000000 mmcr0 0x0000000000000000 mmcr2 0x0000000000000000 siar 0x0000000000000000 sdar 0x0000000000000000 sier 0x0000000000000000 orig_r3 0x00007ffff765b61c trap 0x0000000000000380 =E2=94=80=E2=94=80=E2=94=80 Source =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 57=20=20 58 if (cur =3D=3D NULL) 59 { 60 /* Exit processing complete. We will not allow any more 61 atexit/on_exit registrations. */ 62 __exit_funcs_done =3D true; 63 break; 64 } 65=20=20 66 while (cur->idx > 0) =E2=94=80=E2=94=80=E2=94=80 Stack =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 [0] from 0x00007ffff765b7cc in __run_exit_handlers+620 at exit.c:62 [1] from 0x00007ffff765b948 in __GI_exit+40 at exit.c:143 [2] from 0x00007ffff7637fb8 in __libc_start_call_main+168 at ../sysdeps/nptl/libc_start_call_main.h:74 [3] from 0x00007ffff76381ec in generic_start_main+252 at ../csu/libc-start.c:381 [4] from 0x00007ffff76381ec in __libc_start_main_impl+428 at ../sysdeps/unix/sysv/linux/powerpc/libc-start.c:109 [5] from 0x0000000000000000 =E2=94=80=E2=94=80=E2=94=80 Threads =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80 [1] id 3179009 name a.out from 0x00007ffff765b7cc in __run_exit_handlers+62= 0 at exit.c:62 =E2=94=80=E2=94=80=E2=94=80 Variables =E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80 arg status =3D , listp =3D 0x7ffff7860ad0 <__exit_funcs>: Ca= nnot access memory at address 0x0, run_list_atexit =3D true, run_dtors =3D true loc cur =3D The preprocessed source was generated from the libstdc++ testsuite like so: $ $GCC/bin/g++ -O2 ~/src/gcc/libstdc++-v3/testsuite/ext/throw_allocator/check_deallocate_null.= cc -I ~/src/gcc/libstdc++-v3/testsuite/util/ -ffunction-sections -Wl,--gc-sect= ions -D_GLIBCXX_DEBUG -Wl,-rpath,$GCC/lib64 -save-temps -v && ./a.out Using built-in specs. COLLECT_GCC=3D/tmp/usr/local/bin/g++ COLLECT_LTO_WRAPPER=3D/tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown= -linux-gnu/14.0.0/lto-wrapper Target: powerpc64le-unknown-linux-gnu Configured with: /home/test/src/gcc/configure --enable-languages=3Dc++,c --disable-nls --without-isl --disable-libitm --disable-libssp --disable-lib= gomp --disable-libvtv --disable-libcc1 --disable-libsanitizer --disable-libstdcxx-pch --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230516 (experimental) (GCC)=20 COLLECT_GCC_OPTIONS=3D'-O2' '-I' '/home/test/src/gcc/libstdc++-v3/testsuite/util/' '-ffunction-sections' '-D' '_GLIBCXX_DEBUG' '-save-temps' '-v' '-shared-libgcc' '-dumpdir' 'a-' /tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/14.0.0/cc1= plus -E -quiet -v -I /home/test/src/gcc/libstdc++-v3/testsuite/util/ -iprefix /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/ -D_GNU_SOURCE -D _GLIBCXX_DEBUG /home/test/src/gcc/libstdc++-v3/testsuite/ext/throw_allocator/check_dealloc= ate_null.cc -ffunction-sections -O2 -fpch-preprocess -o a-check_deallocate_null.ii ignoring nonexistent directory "/tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/../../.= ./../powerpc64le-unknown-linux-gnu/include" ignoring duplicate directory "/tmp/usr/local/bin/../lib/gcc/../../lib/gcc/powerpc64le-unknown-linux-gnu/= 14.0.0/../../../../include/c++/14.0.0" ignoring duplicate directory "/tmp/usr/local/bin/../lib/gcc/../../lib/gcc/powerpc64le-unknown-linux-gnu/= 14.0.0/../../../../include/c++/14.0.0/powerpc64le-unknown-linux-gnu" ignoring duplicate directory "/tmp/usr/local/bin/../lib/gcc/../../lib/gcc/powerpc64le-unknown-linux-gnu/= 14.0.0/../../../../include/c++/14.0.0/backward" ignoring duplicate directory "/tmp/usr/local/bin/../lib/gcc/../../lib/gcc/powerpc64le-unknown-linux-gnu/= 14.0.0/include" ignoring duplicate directory "/tmp/usr/local/bin/../lib/gcc/../../lib/gcc/powerpc64le-unknown-linux-gnu/= 14.0.0/include-fixed" ignoring nonexistent directory "/tmp/usr/local/bin/../lib/gcc/../../lib/gcc/powerpc64le-unknown-linux-gnu/= 14.0.0/../../../../powerpc64le-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/test/src/gcc/libstdc++-v3/testsuite/util/ /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/../../..= /../include/c++/14.0.0 /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/../../..= /../include/c++/14.0.0/powerpc64le-unknown-linux-gnu /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/../../..= /../include/c++/14.0.0/backward /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/include /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/include-= fixed /usr/local/include /usr/include End of search list. COLLECT_GCC_OPTIONS=3D'-O2' '-I' '/home/test/src/gcc/libstdc++-v3/testsuite/util/' '-ffunction-sections' '-D' '_GLIBCXX_DEBUG' '-save-temps' '-v' '-shared-libgcc' '-dumpdir' 'a-' /tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/14.0.0/cc1= plus -fpreprocessed a-check_deallocate_null.ii -quiet -dumpdir a- -dumpbase check_deallocate_null.cc -dumpbase-ext .cc -O2 -version -ffunction-sections= -o a-check_deallocate_null.s GNU C++17 (GCC) version 14.0.0 20230516 (experimental) (powerpc64le-unknown-linux-gnu) compiled by GNU C version 12.3.1 20230508 (Red Hat 12.3.1-1), GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version none GGC heuristics: --param ggc-min-expand=3D30 --param ggc-min-heapsize=3D4096 Compiler executable checksum: 5613d942ec03ccc046b8b073d0c66526 COLLECT_GCC_OPTIONS=3D'-O2' '-I' '/home/test/src/gcc/libstdc++-v3/testsuite/util/' '-ffunction-sections' '-D' '_GLIBCXX_DEBUG' '-save-temps' '-v' '-shared-libgcc' '-dumpdir' 'a-' as -v -I /home/test/src/gcc/libstdc++-v3/testsuite/util/ -a64 -mpower8 -mlittle -o a-check_deallocate_null.o a-check_deallocate_null.s GNU assembler version 2.38 (ppc64le-redhat-linux) using BFD version version 2.38-27.fc37 COMPILER_PATH=3D/tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux= -gnu/14.0.0/:/tmp/usr/local/bin/../libexec/gcc/ LIBRARY_PATH=3D/tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/= 14.0.0/:/tmp/usr/local/bin/../lib/gcc/:/tmp/usr/local/bin/../lib/gcc/powerp= c64le-unknown-linux-gnu/14.0.0/../../../../lib64/:/lib/../lib64/:/usr/lib/.= ./lib64/:/tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0= /../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS=3D'-O2' '-I' '/home/test/src/gcc/libstdc++-v3/testsuite/util/' '-ffunction-sections' '-D' '_GLIBCXX_DEBUG' '-save-temps' '-v' '-shared-libgcc' '-dumpdir' 'a.' /tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/14.0.0/coll= ect2 -plugin /tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/14.0.0/libl= to_plugin.so -plugin-opt=3D/tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-g= nu/14.0.0/lto-wrapper -plugin-opt=3D-fresolution=3Da.res -plugin-opt=3D-pass-through=3D-lgcc_s -plugin-opt=3D-pass-through=3D-lgcc -plugin-opt=3D-pass-through=3D-lc -plugin-opt=3D-pass-through=3D-lgcc_s -plugin-opt=3D-pass-through=3D-lgcc --eh-frame-hdr -V -m elf64lppc -dynamic-linker /lib64/ld64.so.2 /lib/../lib64/crt1.o /lib/../lib64/crti.o /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/crtbegin= .o -L/tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0 -L/tmp/usr/local/bin/../lib/gcc -L/tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/../../= ../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/../../= .. a-check_deallocate_null.o --gc-sections -rpath /tmp/usr/local/lib64 -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /tmp/usr/local/bin/../lib/gcc/powerpc64le-unknown-linux-gnu/14.0.0/crtend.o /lib/../lib64/crtn.o GNU ld version 2.38-27.fc37 Supported emulations: elf64lppc elf32lppc elf32lppclinux elf32lppcsim elf64ppc elf32ppc elf32ppclinux elf32ppcsim elf32_spu i386pep i386pe elf64bpf COLLECT_GCC_OPTIONS=3D'-O2' '-I' '/home/test/src/gcc/libstdc++-v3/testsuite/util/' '-ffunction-sections' '-D' '_GLIBCXX_DEBUG' '-save-temps' '-v' '-shared-libgcc' '-dumpdir' 'a.' Segmentation fault (core dumped) I see this on power 9 fedora 37 (glibc-2.36) but not on power 8 centos 7.9 (glibc-2.17).=