From 20f5b7139f869e35f32d720ff611c7051b36e774 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Mon, 30 Oct 2023 11:58:52 -0700 Subject: [PATCH] [armv7l] Work around `mcontext_t` structure mismatch Jameson points out that ARM doesn't use the usual structure for these registers, and so we have to manually typecast this structure. X-ref: https://github.com/JuliaLang/julia/issues/47345#issuecomment-1293706173 --- src/stackwalk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/stackwalk.c b/src/stackwalk.c index 6efb177927637e..e95db9375eec0d 100644 --- a/src/stackwalk.c +++ b/src/stackwalk.c @@ -919,7 +919,14 @@ static void jl_rec_backtrace(jl_task_t *t) JL_NOTSAFEPOINT memset(&c, 0, sizeof(c)); #if defined(_OS_LINUX_) && defined(__GLIBC__) __jmp_buf *mctx = &t->ctx.ctx.uc_mcontext->__jmpbuf; + #if defined(_CPU_ARM_) + // The libunwind-arm.h header defines its own copy of `ucontext_t` instead + // of using the platform definition directly. + // https://github.com/libunwind/libunwind/blob/fbaa4d5b0c47a4129ff7e514bdecc284635b36e9/include/libunwind-arm.h#L258-L266 + mcontext_t *mc = (mcontext_t *)&c; + #else mcontext_t *mc = &c.uc_mcontext; + #endif #if defined(_CPU_X86_) // https://github.com/bminor/glibc/blame/master/sysdeps/i386/__longjmp.S // https://github.com/bminor/glibc/blame/master/sysdeps/i386/jmpbuf-offsets.h