From 9dae9b31d2c7834de72a27c6d635ebeab53cebc6 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 6 Nov 2026 16:26:18 +0200 Subject: [PATCH] libthr: require both _Unwind_ForcedUnwind and _Unwind_GetCFA for !PIC Static linking must bring in both symbols for the unwind to work. The landing pads added by 2734bbbcba3c reference _Unwind_Resume and __gcc_personality_v0. In a static link, these pull UnwindLevel1.o from libgcc_eh.a, which also defines _Unwind_ForcedUnwind, but not UnwindLevel1-gcc-ext.o, which defines _Unwind_GetCFA. Unless something else pulls that object in, as libcxxrt does for C++ programs, thread_unwind_stop() calls a NULL _Unwind_GetCFA on every thread exit. Reported and tested by: dch Fixes: 2734bbbcba3c ("libthr: Create landing pad in thr_once in C++ exception") Sponsored by: The FreeBSD Foundation --- lib/libthr/thread/thr_exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c index 4c9692ccf1a5..8929ed5a9f11 100644 --- a/lib/libthr/thread/thr_exit.c +++ b/lib/libthr/thread/thr_exit.c @@ -241,7 +241,7 @@ _pthread_exit_mask(void *status, sigset_t *mask) thread_uw_init(); if (uwl_forcedunwind != NULL) { #else - if (_Unwind_ForcedUnwind != NULL) { + if (_Unwind_ForcedUnwind != NULL && _Unwind_GetCFA != NULL) { #endif if (curthread->unwind_disabled) { if (message_printed == 0) {