From a15d2d582b4015af0f72caa2b5f09b7e665e2c1e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 7 Feb 2022 17:11:26 -0800 Subject: [PATCH] stage2: fix crash_report segfault compile error Regressed in 05cf69209e44c59f838f94ab355485d2d3a0432a. --- src/crash_report.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/crash_report.zig b/src/crash_report.zig index 724269556b..7e72c64800 100644 --- a/src/crash_report.zig +++ b/src/crash_report.zig @@ -4,6 +4,7 @@ const debug = std.debug; const os = std.os; const io = std.io; const print_zir = @import("print_zir.zig"); +const native_os = builtin.os.tag; const Module = @import("Module.zig"); const Sema = @import("Sema.zig"); @@ -233,9 +234,15 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any }, .aarch64 => ctx: { const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); - const ip = @intCast(usize, ctx.mcontext.pc); + const ip = switch (native_os) { + .macos => @intCast(usize, ctx.mcontext.ss.pc), + else => @intCast(usize, ctx.mcontext.pc), + }; // x29 is the ABI-designated frame pointer - const bp = @intCast(usize, ctx.mcontext.regs[29]); + const bp = switch (native_os) { + .macos => @intCast(usize, ctx.mcontext.ss.fp), + else => @intCast(usize, ctx.mcontext.regs[29]), + }; break :ctx StackContext{ .exception = .{ .bp = bp, .ip = ip } }; }, else => .not_supported,