On Tue, Feb 18, 2025 at 08:23:15PM +0100, Richard Biener wrote: > > Am 18.02.2025 um 20:07 schrieb Roman Kagan <rka...@amazon.de>: > > On Tue, Feb 18, 2025 at 07:17:24PM +0100, Uros Bizjak wrote: > >>> On Mon, Feb 17, 2025 at 6:19 PM Roman Kagan <rka...@amazon.de> wrote: > >>> On Thu, Jan 02, 2025 at 04:32:17PM +0100, Roman Kagan wrote: > >>>> When gcc is built for x86_64-linux-musl target, stack unwinding from > >>>> within signal handler stops at the innermost signal frame. The reason > >>>> for this behaviro is that the signal trampoline is not accompanied with > >>>> appropiate CFI directives, and the fallback path in libgcc to recognize > >>>> it by the code sequence is only enabled for glibc except 2.0. The > >>>> latter is motivated by the lack of sys/ucontext.h in that glibc version. > >>>> > >>>> Given that all relevant libc-s ship sys/ucontext.h for over a decade, > >>>> and that other arches aren't shy of unconditionally using it, follow > >>>> suit and remove the preprocessor condition, too. > >> > >> "Relevant libc"-s for x86 linux are LIBC_GLIBC, LIBC_UCLIBC, > >> LIBC_BIONIC and LIBC_MUSL. As far as glibc is concerned, the latest > >> glibc 2.0.x version was released in 1997 [1], so I guess we can remove > >> the condition for version 2.0. Based on your claim, the other > >> mentioned libcs also provide the required header for a long time. > > [...] You should possibly see to add the missing CFI directives on > your system?
Indeed. Out of the four libcs listed, two -- glibc and bionic -- have CFI in their signal trampolines, the other two -- musl and uClibc-ng -- don't. Musl, which I happen to use right now, is not very friendly with unwinding in general: it passes -fno-unwind-tables -fno-asynchronous-unwind-tables to the compiler, it has (almost) no support for CFI in assembly sources, and so on. So patching libgcc_eh to use the fallback for signal frames on x86 as it does on other arches looked like a reasonable start, but yes, I still have work to do to make unwinding work through library functions too. Thanks, Roman.