https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106581
Bug ID: 106581 Summary: [Aarch64] libstdc++ segfault at end of execution Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: lancethepants at gmail dot com Target Milestone: --- aarch64 linux 4.1.51 GCC 12.1 uclibc-ng 1.0.41 All dynamically linked c++ executables will segfault. Some executables will run then segfault, some just segfault. I think there are couple segfaulting issues, but this is the first one to address I think. GCC 10 & 11 don't segfault at the end of execution if they don't segfault for some other reason. Static linked binaries don't segfault at the end of execution using either '-static' for fully static binary or '-static-libstdc++' to static link just libstdc++. Here is a backtrace of segfaulting 'hello world' c++ binary admin@RT-AX88U-6860:~/src/hello.src# /opt/bin/gdb ./hello GNU gdb (GDB) 11.2 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "aarch64-openwrt-linux". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./hello... (gdb) run Starting program: /mmc/src/hello.src/hello warning: Unable to determine the number of hardware watchpoints available. warning: Unable to determine the number of hardware breakpoints available. warning: File "/mmc/lib/libthread_db-1.0.41.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". To enable execution of this file add add-auto-load-safe-path /mmc/lib/libthread_db-1.0.41.so line to your configuration file "/mmc/.config/gdb/gdbinit". To completely disable this security protection add set auto-load safe-path / line to your configuration file "/mmc/.config/gdb/gdbinit". For more information about this security protection see the "Auto-loading safe path" section in the GDB manual. E.g., run from the shell: info "(gdb)Auto-loading safe path" warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. Hello, World from C++! Program received signal SIGSEGV, Segmentation fault. std::uncaught_exception () at ../../../../libstdc++-v3/libsupc++/eh_catch.cc:141 141 ../../../../libstdc++-v3/libsupc++/eh_catch.cc: No such file or directory. (gdb) backtrace #0 std::uncaught_exception () at ../../../../libstdc++-v3/libsupc++/eh_catch.cc:141 #1 0x0000007fb7f0bd30 in std::ostream::sentry::~sentry (this=0x7ffffff340, __in_chrg=<optimized out>) at /home/lance/tomatoware/toolchain/buildroot-git/output/build/host-gcc-final-12.1.0/build/aarch64-tomatoware-linux-uclibc/libstdc++-v3/include/ostream:466 #2 0x0000007fb7f0bde4 in std::ostream::flush (this=0x7fb7fe4f48 <std::cerr>) at /home/lance/tomatoware/toolchain/buildroot-git/output/build/host-gcc-final-12.1.0/build/aarch64-tomatoware-linux-uclibc/libstdc++-v3/include/bits/ostream.tcc:245 #3 0x0000007fb7ebbc40 in std::ios_base::Init::~Init (this=<optimized out>, __in_chrg=<optimized out>) at ../../../../../libstdc++-v3/src/c++98/ios_init.cc:135 #4 0x0000007fb7d401b8 in __exit_handler (status=0) at libc/stdlib/_atexit.c:263 #5 0x0000007fb7d402b8 in __GI_exit (rv=0) at libc/stdlib/_atexit.c:301 #6 0x0000007fb7d46134 in __uClibc_main (main=0x55555559d4 <main()>, argc=1, argv=0x7ffffff598, app_init=0x55555557d8 <_init>, app_fini=0x5555555a78 <_fini>, rtld_fini=0x7fb7fe94f0 <_dl_fini>, stack_end=0x7ffffff590) at libc/misc/internals/__uClibc_main.c:552 #7 0x00000055555558c4 in _start () at libc/sysdeps/linux/aarch64/crt1.S:92 Backtrace stopped: previous frame identical to this frame (corrupt stack?)