From 9638ba0e064e10f3f0738371970ea6623845219d Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 25 Jan 2021 23:35:22 -0500 Subject: [PATCH 1/2] fix linux unwind info, per x86_64 ABI Closes #23074 Fixes #35155 --- src/task.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/task.c b/src/task.c index 5460e79618ba6..345176a98dd5f 100644 --- a/src/task.c +++ b/src/task.c @@ -807,10 +807,25 @@ STATIC_OR_JS void NOINLINE JL_NORETURN start_task(void) { #ifdef _OS_WINDOWS_ #if defined(_CPU_X86_64_) - // install the unhandled exception hanlder at the top of our stack + // install the unhandled exception handler at the top of our stack // to call directly into our personality handler asm volatile ("\t.seh_handler __julia_personality, @except\n\t.text"); #endif +#else + // wipe out the call-stack unwind capability beyond this function + // (we are noreturn, so it is not a total lie) +#if defined(_CPU_X86_64_) + // per nongnu libunwind: "x86_64 ABI specifies that end of call-chain is marked with a NULL RBP or undefined return address" + // so we do all 3, to be extra certain of it + asm volatile ("\t.cfi_undefined rip"); + asm volatile ("\t.cfi_undefined rbp"); + asm volatile ("\t.cfi_return_column rbp"); +#else + // per nongnu libunwind: "DWARF spec says undefined return address location means end of stack" + // we use whatever happens to be register 1 on this platform for this + asm volatile ("\t.cfi_undefined 1"); + asm volatile ("\t.cfi_return_column 1"); +#endif #endif // this runs the first time we switch to a task From d1fa5a57acff6ebe51424dca71f6e962d86d28b1 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 25 Jan 2021 23:35:56 -0500 Subject: [PATCH 2/2] build: fix libunwind configure flags --- deps/unwind.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/unwind.mk b/deps/unwind.mk index 351f9b3df745f..c51adfe63dce0 100644 --- a/deps/unwind.mk +++ b/deps/unwind.mk @@ -27,7 +27,7 @@ $(SRCCACHE)/libunwind-$(UNWIND_VER)/libunwind-static-arm.patch-applied: $(SRCCAC $(BUILDDIR)/libunwind-$(UNWIND_VER)/build-configured: $(SRCCACHE)/libunwind-$(UNWIND_VER)/source-extracted $(SRCCACHE)/libunwind-$(UNWIND_VER)/libunwind-static-arm.patch-applied mkdir -p $(dir $@) cd $(dir $@) && \ - $(dir $<)/configure $(CONFIGURE_COMMON) CPPFLAGS="$(CPPFLAGS) $(LIBUNWIND_CPPFLAGS)" CFLAGS="$(CFLAGS) $(LIBUNWIND_CFLAGS)" --disable-shared --disable-minidebuginfo --disable-tests + $(dir $<)/configure $(CONFIGURE_COMMON) CPPFLAGS="$(CPPFLAGS) $(LIBUNWIND_CPPFLAGS)" CFLAGS="$(CFLAGS) $(LIBUNWIND_CFLAGS)" --enable-shared --disable-minidebuginfo --disable-tests echo 1 > $@ $(BUILDDIR)/libunwind-$(UNWIND_VER)/build-compiled: $(BUILDDIR)/libunwind-$(UNWIND_VER)/build-configured