authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-10 12:53:03+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-30 13:44:52+01:00
logbfbbda77517ec83ef7cfacced651acc9d85b8bb0
tree1b7e28ae7fcb0541f8cce15b36fd4fbabfcdd719
parentc1a30bd0d876330ce7a241fc297c66577ae7e6aa
signaturelock-open Commit is signed but in an unrecognized format.

compiler: fix new panic handler in release builds


2 files changed, 5 insertions(+), 3 deletions(-)

lib/std/debug.zig+2-2
...@@ -355,7 +355,7 @@ pub fn relocateContext(dest: *ThreadContext) void {...@@ -355,7 +355,7 @@ pub fn relocateContext(dest: *ThreadContext) void {
355/// The value which is placed on the stack to make a copy of a `ThreadContext`.355/// The value which is placed on the stack to make a copy of a `ThreadContext`.
356const ThreadContextBuf = if (ThreadContext == noreturn) void else ThreadContext;356const ThreadContextBuf = if (ThreadContext == noreturn) void else ThreadContext;
357/// The pointer through which a `ThreadContext` is received from callers of stack tracing logic.357/// The pointer through which a `ThreadContext` is received from callers of stack tracing logic.
358const ThreadContextPtr = if (ThreadContext == noreturn) noreturn else *const ThreadContext;358pub const ThreadContextPtr = if (ThreadContext == noreturn) noreturn else *const ThreadContext;
359359
360/// Capture the current context. The register values in the context will reflect the360/// Capture the current context. The register values in the context will reflect the
361/// state after the platform `getcontext` function returns.361/// state after the platform `getcontext` function returns.
...@@ -1297,7 +1297,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa...@@ -1297,7 +1297,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa
1297 if (ThreadContext == noreturn) return handleSegfault(addr, name, null);1297 if (ThreadContext == noreturn) return handleSegfault(addr, name, null);
12981298
1299 // Some kernels don't align `ctx_ptr` properly, so we'll copy it into a local buffer.1299 // Some kernels don't align `ctx_ptr` properly, so we'll copy it into a local buffer.
1300 var copied_ctx: ThreadContextBuf = undefined;1300 var copied_ctx: posix.ucontext_t = undefined;
1301 const orig_ctx: *align(1) posix.ucontext_t = @ptrCast(ctx_ptr);1301 const orig_ctx: *align(1) posix.ucontext_t = @ptrCast(ctx_ptr);
1302 copied_ctx = orig_ctx.*;1302 copied_ctx = orig_ctx.*;
1303 if (builtin.os.tag.isDarwin() and builtin.cpu.arch == .aarch64) {1303 if (builtin.os.tag.isDarwin() and builtin.cpu.arch == .aarch64) {
src/crash_report.zig+3-1
...@@ -17,7 +17,7 @@ pub const debug = struct {...@@ -17,7 +17,7 @@ pub const debug = struct {
17/// crash earlier than that.17/// crash earlier than that.
18pub var zig_argv0: []const u8 = "zig";18pub var zig_argv0: []const u8 = "zig";
1919
20fn handleSegfaultImpl(addr: ?usize, name: []const u8, opt_ctx: ?*std.debug.ThreadContext) noreturn {20fn handleSegfaultImpl(addr: ?usize, name: []const u8, opt_ctx: ?std.debug.ThreadContextPtr) noreturn {
21 @branchHint(.cold);21 @branchHint(.cold);
22 dumpCrashContext() catch {};22 dumpCrashContext() catch {};
23 std.debug.defaultHandleSegfault(addr, name, opt_ctx);23 std.debug.defaultHandleSegfault(addr, name, opt_ctx);
...@@ -56,6 +56,7 @@ pub const AnalyzeBody = if (build_options.enable_debug_extensions) struct {...@@ -56,6 +56,7 @@ pub const AnalyzeBody = if (build_options.enable_debug_extensions) struct {
56 current = ab.parent;56 current = ab.parent;
57 }57 }
58} else struct {58} else struct {
59 const current: ?noreturn = null;
59 // Dummy implementation, with functions marked `inline` to avoid interfering with tail calls.60 // Dummy implementation, with functions marked `inline` to avoid interfering with tail calls.
60 pub inline fn push(_: AnalyzeBody, _: *Sema, _: *Sema.Block, _: []const Zir.Inst.Index) void {}61 pub inline fn push(_: AnalyzeBody, _: *Sema, _: *Sema.Block, _: []const Zir.Inst.Index) void {}
61 pub inline fn pop(_: AnalyzeBody) void {}62 pub inline fn pop(_: AnalyzeBody) void {}
...@@ -75,6 +76,7 @@ pub const CodegenFunc = if (build_options.enable_debug_extensions) struct {...@@ -75,6 +76,7 @@ pub const CodegenFunc = if (build_options.enable_debug_extensions) struct {
75 current = null;76 current = null;
76 }77 }
77} else struct {78} else struct {
79 const current: ?noreturn = null;
78 // Dummy implementation80 // Dummy implementation
79 pub fn start(_: *const Zcu, _: InternPool.Index) void {}81 pub fn start(_: *const Zcu, _: InternPool.Index) void {}
80 pub fn stop(_: InternPool.Index) void {}82 pub fn stop(_: InternPool.Index) void {}