Recent update triggers random crashes on startup when using address sanitizer

Hey there,

a recent update, probably from this week, triggered a situation that leads to intermittent crashes on startup of applications using ASAN.

Description:

Launching an ASAN application sometimes crashes on startup with ERROR: AddressSanitizer: SEGV on unknown address.

Using clang, I cannot reproduce that issue. Furthermore, a colleague tested it on nix with Gcc 13.2 and also could not reproduce the issue there. This makes me believe it's an archlinux gcc issue somehow?

Additional info:

  • package version(s): core/gcc 13.2.1-3
  • config and/or log files: ? which ones are you looking for?
  • link to upstream bug report, if any: I don't think it's an upstream bug

Steps to reproduce:

to reproduce this is enough for me:

#include <iostream>

int main()
{
    std::cout << "Works\n";
    return 0;
}
$ g++ -g -fsanitize=address test.cpp -o test
$ while true; do ./test || break; done
Works
Works
Works
Works
AddressSanitizer:DEADLYSIGNAL
=================================================================
==331888==ERROR: AddressSanitizer: SEGV on unknown address 0x629315caee28 (pc 0x7e438280338f bp 0x000000000000 sp 0x7ffc5452a510 T0)
==331888==The signal is caused by a READ memory access.
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer: nested bug in the same thread, aborting.

With rr I managed to get a backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00007fa48084938f in ?? () from /lib64/ld-linux-x86-64.so.2
(rr) bt
#0  0x00007fa48084938f in ?? () from /lib64/ld-linux-x86-64.so.2
#1  0x00007fa48084a0b8 in ?? () from /lib64/ld-linux-x86-64.so.2
#2  0x00007fa47fb7300e in ?? () from /usr/lib/libc.so.6
#3  0x00007fa47faa6ae8 in ?? () from /usr/lib/libc.so.6
#4  0x00007fa4808414e1 in _dl_catch_exception () from /lib64/ld-linux-x86-64.so.2
#5  0x00007fa480841603 in ?? () from /lib64/ld-linux-x86-64.so.2
#6  0x00007fa47faa64f7 in ?? () from /usr/lib/libc.so.6
#7  0x00007fa47faa6b75 in dlsym () from /usr/lib/libc.so.6
#8  0x00007fa4800fffb3 in __sanitizer::ThreadDescriptorSize () at /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp:298
#9  0x00007fa4801017ae in __sanitizer::ThreadDescriptorSize () at /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp:294
#10 __sanitizer::GetTls (size=0x7fff09d8da38, addr=0x7fa48081b040) at /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp:498
#11 __sanitizer::GetThreadStackAndTls (main=true, stk_addr=stk_addr@entry=0x7fa48081b020, stk_size=stk_size@entry=0x7fff09d8da40, tls_addr=tls_addr@entry=0x7fa48081b040, tls_size=tls_size@entry=0x7fff09d8da38)
    at /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp:595
#12 0x00007fa4800f0ff4 in __asan::AsanThread::SetThreadStackAndTls (this=this@entry=0x7fa48081b000, options=<optimized out>) at /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_thread.h:77
#13 0x00007fa4800f14ee in __asan::AsanThread::Init (this=this@entry=0x7fa48081b000, options=options@entry=0x0) at /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_thread.cpp:234
#14 0x00007fa4800f19e5 in __asan::AsanThread::ThreadStart (this=this@entry=0x7fa48081b000, os_id=332151) at /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_thread.cpp:264
#15 0x00007fa4800f2604 in __asan::CreateMainThread () at /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_thread.cpp:295
#16 0x00007fa4800ee9df in __asan::AsanInitInternal () at /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_rtl.cpp:480
#17 0x00007fa48084502a in ?? () from /lib64/ld-linux-x86-64.so.2
#18 0x00007fa48085b2d0 in ?? () from /lib64/ld-linux-x86-64.so.2
#19 0x0000000000000001 in ?? ()
#20 0x00007fff09d8f9fc in ?? ()
#21 0x0000000000000000 in ?? ()