authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-12 03:24:24+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-30 13:44:53+01:00
log344ab62b3fa4fc286b76a51ac47f0b8363339bee
tree0b89d332e961a968854142697ed72a55b8a1522f
parentcf13b40946d5fbac1eb8963418a19b12a69023e8
signaturelock-open Commit is signed but in an unrecognized format.

std.debug: don't attempt SelfInfo unwinding when unsupported


1 files changed, 9 insertions(+), 2 deletions(-)

lib/std/debug.zig+9-2
......@@ -678,6 +678,12 @@ pub fn writeCurrentStackTrace(options: StackUnwindOptions, writer: *Writer, tty_
678678 tty_config.setColor(writer, .reset) catch {};
679679 return;
680680 },
681 error.CannotUnwindFromContext => {
682 tty_config.setColor(writer, .dim) catch {};
683 try writer.print("Cannot print stack trace: context unwind unavailable for target\n", .{});
684 tty_config.setColor(writer, .reset) catch {};
685 return;
686 },
681687 };
682688 defer it.deinit();
683689 if (!it.stratOk(options.allow_unsafe_unwind)) {
......@@ -787,7 +793,7 @@ const StackIterator = union(enum) {
787793 /// It is important that this function is marked `inline` so that it can safely use
788794 /// `@frameAddress` and `getContext` as the caller's stack frame and our own are one
789795 /// and the same.
790 inline fn init(context_opt: ?ThreadContextPtr, context_buf: *ThreadContextBuf) error{OutOfMemory}!StackIterator {
796 inline fn init(context_opt: ?ThreadContextPtr, context_buf: *ThreadContextBuf) error{ OutOfMemory, CannotUnwindFromContext }!StackIterator {
791797 if (builtin.cpu.arch.isSPARC()) {
792798 // Flush all the register windows on stack.
793799 if (builtin.cpu.has(.sparc, .v9)) {
......@@ -797,11 +803,12 @@ const StackIterator = union(enum) {
797803 }
798804 }
799805 if (context_opt) |context| {
806 if (!SelfInfo.supports_unwinding) return error.CannotUnwindFromContext;
800807 context_buf.* = context.*;
801808 relocateContext(context_buf);
802809 return .{ .di = try .init(context_buf, getDebugInfoAllocator()) };
803810 }
804 if (getContext(context_buf)) {
811 if (SelfInfo.supports_unwinding and getContext(context_buf)) {
805812 return .{ .di = try .init(context_buf, getDebugInfoAllocator()) };
806813 }
807814 return .{ .fp = @frameAddress() };