Bug#1108414: libc++1-19: should not use libunwind, it can always cause a mess with libgcc_s
Norbert Lange
nolange79 at gmail.com
Fri Jun 27 22:41:55 BST 2025
Package: libc++abi1-19
Version: 1:19.1.7-3+b1
Severity: important
X-Debbugs-Cc: nolange79 at gmail.com
On systems using glibc there are apparently some ways libgcc_s is dynamically
loaded during backtrace or stack unwinding.
libunwind and libgcc_s then have conflicting definitions, which typically leads to a seqfault.
The issue is discussed at https://reviews.llvm.org/D106703, I also made an issue at
https://github.com/llvm/llvm-project/issues/90041.
Tough it seems specific to debian, and as far as I understand you should not
use libunwind with glibc as libgcc_s will be always mixed in.
In a distro based on glibc, libunwind should probably not be used at all,
removing it from libc++abi1 should atleast make libc++ work.
Simple example:
------
#include <pthread.h>
#include <thread>
extern "C" int main()
{
std::thread systhr([]() { std::this_thread::sleep_for(std::chrono::seconds(10000)); });
std::this_thread::sleep_for(std::chrono::seconds(1));
pthread_cancel(systhr.native_handle());
systhr.join();
return 0;
}
------
Compile the code with either unwind library:
clang++ -stdlib=libc++ test.cpp
clang++ -stdlib=libc++ -unwindlib=libunwind --rtlib=compiler-rt -O2 test.cpp
Running the program will crash, as libgcc's unwinder will *always* be used:
------
#0 0x0000000000000000 in ?? ()
#1 0x00007ffff7e51cb4 in __unw_get_proc_info () at build-llvm/tools/clang/stage2-bins/runtimes/runtimes-bins/libunwind/src/libunwind.cpp:201
#2 0x00007ffff7e571e6 in _Unwind_GetLanguageSpecificData () at build-llvm/tools/clang/stage2-bins/runtimes/runtimes-bins/libunwind/src/UnwindLevel1.c:528
#3 0x00007ffff7e89415 in scan_eh_tab () at build-llvm/tools/clang/stage2-bins/runtimes/runtimes-bins/libcxxabi/src/cxa_personality.cpp:626
#4 __gxx_personality_v0 () at build-llvm/tools/clang/stage2-bins/runtimes/runtimes-bins/libcxxabi/src/cxa_personality.cpp:957
#5 0x00007ffff735a860 in _Unwind_ForcedUnwind_Phase2 (exc=exc at entry=0x7ffff7b65d30, context=context at entry=0x7ffff7b64ce0, frames_p=frames_p at entry=0x7ffff7b64be8) at ../../../src/libgcc/unwind.inc:183
#6 0x00007ffff735af40 in _Unwind_ForcedUnwind (exc=0x7ffff7b65d30, stop=0x7ffff7c04f30 <unwind_stop>, stop_argument=<optimized out>) at ../../../src/libgcc/unwind.inc:218
#7 0x00007ffff7c050b0 in __GI___pthread_unwind (buf=<optimized out>) at ./nptl/unwind.c:130
#8 0x00007ffff7bf9613 in __do_cancel (result=0xffffffffffffffff) at ../sysdeps/nptl/pthreadP.h:273
#9 __syscall_do_cancel () at ./nptl/cancellation.c:109
#10 0x00007ffff7bf969d in __internal_syscall_cancel (a1=a1 at entry=0, a2=a2 at entry=0, a3=<optimized out>, a4=<optimized out>, a5=a5 at entry=0, a6=a6 at entry=0, nr=230) at ./nptl/cancellation.c:61
#11 0x00007ffff7c45f7a in __GI___clock_nanosleep (clock_id=<optimized out>, clock_id at entry=0, flags=flags at entry=0, req=<optimized out>, rem=<optimized out>) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:48
#12 0x00007ffff7c51393 in __GI___nanosleep (req=<optimized out>, rem=<optimized out>) at ../sysdeps/unix/sysv/linux/nanosleep.c:25
#13 0x00007ffff7effceb in __libcpp_thread_sleep_for () at build-llvm/tools/clang/stage2-bins/include/c++/v1/__thread/support/pthread.h:198
#14 sleep_for () at build-llvm/tools/clang/stage2-bins/runtimes/runtimes-bins/libcxx/src/thread.cpp:94
#15 0x000055555555530e in void* std::__1::__thread_proxy[abi:ne190107]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, main::$_0> >(void*) ()
#16 0x00007ffff7bfcb7b in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:448
#17 0x00007ffff7c7a7b8 in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
------
This is also a duplicate of #1071210, but I guess Bugs for llvm-toolchain-18
receive no attention.
-- System Information:
Debian Release: 13.0
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.12.33+deb13-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages libc++abi1-19 depends on:
ii libc6 2.41-9
ii libunwind-19 1:19.1.7-3+b1
libc++abi1-19 recommends no packages.
libc++abi1-19 suggests no packages.
-- no debconf information
More information about the Pkg-llvm-team
mailing list