Date: Thu, 12 Mar 2020 16:53:00 -0700 From: John Baldwin <jhb@FreeBSD.org> To: "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org> Cc: emaste@FreeBSD.org, Dimitry Andric <dim@FreeBSD.org> Subject: Stack unwinding for pthread_exit() Message-ID: <3c53aeda-f77a-0c07-2d33-caa6dfbc1322@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
libthr contains code in thr_exit.c to use libunwind (libgcc_s) to unwind a thread's stack invoking destructors and pthread_cleanup actions. This uses the _Unwind_ForcedUnwind() function provided by libunwind. However, libunwind does not provide this function on ARM platforms that are using the default EHABI for exception unwinding. It is a bit of a silent failure because the dlsym() calls just fail to find the symbols from libgcc_s. I noticed this because I am working on a patch to install the LLVM libunwind headers into /usr/include and use them instead of the libcxxrt headers (not available to C), and the uninstalled include/unwind.h. However, when I do this, arm worlds stop building due to conflicting types for _Unwind_Stop_Fn. One option is to just disable the forced unwinding at compile time by forcing NO_THREAD_UNWIND_STACK on for ARM in libthr/Makefile. I wonder, however, if a better option would be to switch FreeBSD/arm to using DWARF unwinding (via -fdwarf-exceptions) instead? Perhaps we can even have clang default to that for FreeBSD 13.0 and later? Note that this appears to be a regression from switching to the LLVM libunwind as an old image I have that used libgcc_s from gcc4.2.1 does have _Unwind_ForcedUnwind defined and reading the DWARF info I can tell it has the signature for _Unwind_Stop_Fn that libthr expects. I can't quite tell if GCC 4.2.1 was using DWARF unwind info by default though (it seems like it might have been) and was providing the EHABI VRS API on top of that in addition for ARM. Looks like NetBSD forces DWARF exceptions on for ARM, and Watch OS also uses DWARF exceptions. Darwin on ARM uses SjLj exceptions on ARM otherwise. FreeBSD uses SjLj on ARM with thumb because DWARF I think doesn't handle thumb, but we could perhaps default to DWARF when not using SJLJ instead of the default of EHABI? The relevant file for that would be clang/lib/Driver/ToolChains/FreeBSD.cpp, FreeBSD::GetExceptionModel(). -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3c53aeda-f77a-0c07-2d33-caa6dfbc1322>