It's pretty strange, but the upstream fix does not seem to work on Ubuntu, at least not on 24.04. I tried Debian Sid, and there the regular gcc-13 package (13.2.0-24) has no trouble at all with the test case: no alignment issue, no segfaults.
Program received signal SIGSEGV, Segmentation fault.
0x00007f5b91d9ba44 in __interception::InterceptFunction (name=0x7f5b91dc5717 "strcat", ptr_to_real=0x7f5b91d44128 <__interception::real_strcat>, func=140031265358128, trampoline=140031265358128)
at /home/ubuntu/src/gcc/master/libsanitizer/interception/interception_linux.cpp:62
warning: Source file is more recent than executable.
62 *ptr_to_real = (uptr)addr;
(gdb) bt
#0 0x00007f5b91d9ba44 in __interception::InterceptFunction (name=0x7f5b91dc5717 "strcat", ptr_to_real=0x7f5b91d44128 <__interception::real_strcat>, func=140031265358128,
trampoline=140031265358128) at /home/ubuntu/src/gcc/master/libsanitizer/interception/interception_linux.cpp:62
#1 0x00007f5b91d477d4 in __asan::InitializeAsanInterceptors () at /home/ubuntu/src/gcc/master/libsanitizer/asan/asan_interceptors.cpp:759
#2 0x00007f5b91d5c2b1 in __asan::AsanInitInternal () at /home/ubuntu/src/gcc/master/libsanitizer/asan/asan_rtl.cpp:446
#3 0x00007f5b91d5c819 in __asan_init () at /home/ubuntu/src/gcc/master/libsanitizer/asan/asan_rtl.cpp:626
#4 0x00007f5b92345873 in _dl_init (main_map=0x7f5b923792e0, argc=1, argv=0x7fffed4940b8, env=0x7fffed4940c8) at ./elf/dl-init.c:106
#5 0x00007f5b9235f5a0 in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000001 in ?? ()
#7 0x00007fffed495667 in ?? ()
#8 0x0000000000000000 in ?? ()
It's pretty strange, but the upstream fix does not seem to work on Ubuntu, at least not on 24.04. I tried Debian Sid, and there the regular gcc-13 package (13.2.0-24) has no trouble at all with the test case: no alignment issue, no segfaults.
Whereas on Ubuntu 24.04, anything after upstream's https:/ /gcc.gnu. org/git/ ?p=gcc. git;a=commit; h=28219f7f99a80 519d1c6ab5e5dc8 3b4c7f8d7251 (libsanitizer: merge from upstream) and https:/ /gcc.gnu. org/git/ ?p=gcc. git;a=commit; h=aaf0f12175bfc 0a7bdc6c80b8d48 1fb09ae44e25 (libsanitizer: Apply local patches) just segfaults, e.g.:
Program received signal SIGSEGV, Segmentation fault. :InterceptFunct ion (name=0x7f5b91d c5717 "strcat", ptr_to_ real=0x7f5b91d4 4128 <__interception ::real_ strcat> , func=1400312653 58128, trampoline= 140031265358128 ) src/gcc/ master/ libsanitizer/ interception/ interception_ linux.cpp: 62 :InterceptFunct ion (name=0x7f5b91d c5717 "strcat", ptr_to_ real=0x7f5b91d4 4128 <__interception ::real_ strcat> , func=1400312653 58128, 140031265358128 ) at /home/ubuntu/ src/gcc/ master/ libsanitizer/ interception/ interception_ linux.cpp: 62 :InitializeAsan Interceptors () at /home/ubuntu/ src/gcc/ master/ libsanitizer/ asan/asan_ interceptors. cpp:759 :AsanInitIntern al () at /home/ubuntu/ src/gcc/ master/ libsanitizer/ asan/asan_ rtl.cpp: 446 src/gcc/ master/ libsanitizer/ asan/asan_ rtl.cpp: 626 0x7f5b923792e0, argc=1, argv=0x7fffed49 40b8, env=0x7fffed4940c8) at ./elf/dl-init.c:106 ld-linux- x86-64. so.2
0x00007f5b91d9ba44 in __interception:
at /home/ubuntu/
warning: Source file is more recent than executable.
62 *ptr_to_real = (uptr)addr;
(gdb) bt
#0 0x00007f5b91d9ba44 in __interception:
trampoline=
#1 0x00007f5b91d477d4 in __asan:
#2 0x00007f5b91d5c2b1 in __asan:
#3 0x00007f5b91d5c819 in __asan_init () at /home/ubuntu/
#4 0x00007f5b92345873 in _dl_init (main_map=
#5 0x00007f5b9235f5a0 in _dl_start_user () from /lib64/
#6 0x0000000000000001 in ?? ()
#7 0x00007fffed495667 in ?? ()
#8 0x0000000000000000 in ?? ()