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 {
355355/// The value which is placed on the stack to make a copy of a `ThreadContext`.
356356const ThreadContextBuf = if (ThreadContext == noreturn) void else ThreadContext;
357357/// 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
360360/// Capture the current context. The register values in the context will reflect the
361361/// state after the platform `getcontext` function returns.
......@@ -1297,7 +1297,7 @@ fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopa
12971297 if (ThreadContext == noreturn) return handleSegfault(addr, name, null);
12981298
12991299 // 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;
13011301 const orig_ctx: *align(1) posix.ucontext_t = @ptrCast(ctx_ptr);
13021302 copied_ctx = orig_ctx.*;
13031303 if (builtin.os.tag.isDarwin() and builtin.cpu.arch == .aarch64) {
src/crash_report.zig+3-1
......@@ -17,7 +17,7 @@ pub const debug = struct {
1717/// crash earlier than that.
1818pub 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 {
2121 @branchHint(.cold);
2222 dumpCrashContext() catch {};
2323 std.debug.defaultHandleSegfault(addr, name, opt_ctx);
......@@ -56,6 +56,7 @@ pub const AnalyzeBody = if (build_options.enable_debug_extensions) struct {
5656 current = ab.parent;
5757 }
5858} else struct {
59 const current: ?noreturn = null;
5960 // Dummy implementation, with functions marked `inline` to avoid interfering with tail calls.
6061 pub inline fn push(_: AnalyzeBody, _: *Sema, _: *Sema.Block, _: []const Zir.Inst.Index) void {}
6162 pub inline fn pop(_: AnalyzeBody) void {}
......@@ -75,6 +76,7 @@ pub const CodegenFunc = if (build_options.enable_debug_extensions) struct {
7576 current = null;
7677 }
7778} else struct {
79 const current: ?noreturn = null;
7880 // Dummy implementation
7981 pub fn start(_: *const Zcu, _: InternPool.Index) void {}
8082 pub fn stop(_: InternPool.Index) void {}