public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109889] New: [13/14 Regression] Segfault in __run_exit_handlers since r13-5309-gc3c6c307792026
@ 2023-05-17 11:10 redi at gcc dot gnu.org
  2023-05-17 11:17 ` [Bug libstdc++/109889] " redi at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-17 11:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109889

            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=55099&action=edit
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=undefined or if either 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=<optimized out>, 
    listp=0x7ffff7860ad0 <__exit_funcs>, 
    run_list_atexit=run_list_atexit@entry=true, 
    run_dtors=run_dtors@entry=true) at exit.c:62
62                __exit_funcs_done = true;                                   
─── Assembly ─────────────────────────────────────────────────────────────────
 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>
─── Registers ────────────────────────────────────────────────────────────────
             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        
          fpscr 0x0000000000000000            vscr 0x00000000        
         vrsave 0xffffffff                     ppr 0x000c000000000000
           dscr 0x0000000000000010             tar 0x0000000000000000
          mmcr0 0x0000000000000000           mmcr2 0x0000000000000000
           siar 0x0000000000000000            sdar 0x0000000000000000
           sier 0x0000000000000000         orig_r3 0x00007ffff765b61c
           trap 0x0000000000000380
─── Source ───────────────────────────────────────────────────────────────────
 57  
 58        if (cur == NULL)
 59      {
 60        /* Exit processing complete.  We will not allow any more
 61           atexit/on_exit registrations.  */
 62        __exit_funcs_done = true;
 63        break;
 64      }
 65  
 66        while (cur->idx > 0)
─── Stack ────────────────────────────────────────────────────────────────────
[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
─── Threads ──────────────────────────────────────────────────────────────────
[1] id 3179009 name a.out from 0x00007ffff765b7cc in __run_exit_handlers+620 at
exit.c:62
─── Variables ────────────────────────────────────────────────────────────────
arg status = <optimized out>, listp = 0x7ffff7860ad0 <__exit_funcs>: Cannot
access memory at address 0x0, run_list_atexit = true, run_dtors = true
loc cur = <optimized out>



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-sections
-D_GLIBCXX_DEBUG -Wl,-rpath,$GCC/lib64 -save-temps -v  && ./a.out
Using built-in specs.
COLLECT_GCC=/tmp/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/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=c++,c
--disable-nls --without-isl --disable-libitm --disable-libssp --disable-libgomp
--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) 
COLLECT_GCC_OPTIONS='-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/cc1plus
-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_deallocate_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='-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/cc1plus
-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=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 5613d942ec03ccc046b8b073d0c66526
COLLECT_GCC_OPTIONS='-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=/tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/14.0.0/:/tmp/usr/local/bin/../libexec/gcc/
LIBRARY_PATH=/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/powerpc64le-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='-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/collect2
-plugin
/tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/14.0.0/liblto_plugin.so
-plugin-opt=/tmp/usr/local/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/14.0.0/lto-wrapper
-plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-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='-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).

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-05-21  9:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 11:10 [Bug libstdc++/109889] New: [13/14 Regression] Segfault in __run_exit_handlers since r13-5309-gc3c6c307792026 redi at gcc dot gnu.org
2023-05-17 11:17 ` [Bug libstdc++/109889] " redi at gcc dot gnu.org
2023-05-17 11:25 ` jakub at gcc dot gnu.org
2023-05-17 11:26 ` redi at gcc dot gnu.org
2023-05-17 11:30 ` redi at gcc dot gnu.org
2023-05-17 15:04 ` tuliom at ascii dot art.br
2023-05-17 15:10 ` tuliom at ascii dot art.br
2023-05-17 15:50 ` redi at gcc dot gnu.org
2023-05-17 15:57 ` redi at gcc dot gnu.org
2023-05-17 15:58 ` redi at gcc dot gnu.org
2023-05-17 15:59 ` redi at gcc dot gnu.org
2023-05-17 19:38 ` rguenth at gcc dot gnu.org
2023-05-19 12:49 ` redi at gcc dot gnu.org
2023-05-24 12:04 ` redi at gcc dot gnu.org
2023-07-27  9:26 ` rguenth at gcc dot gnu.org
2024-05-21  9:15 ` [Bug libstdc++/109889] [13/14/15 " jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).