authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-28 14:07:24+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-28 14:16:50+02:00
logfb1e767ff8a6f4c32865020e36df4038434ecc65
tree08d90a2612e1fa7daded4c739e707ee41eb483fa
parent9ae517714efba1017e5d0ee76f71c6beda015697
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug: apply stack bias to the frame pointer fetched from the CPU context

Unbreaks segfault stack tracing on SPARC.

1 files changed, 7 insertions(+), 5 deletions(-)

lib/std/debug.zig+7-5
......@@ -1086,10 +1086,12 @@ const StackIterator = union(enum) {
10861086 switch (it.*) {
10871087 .ctx_first => |context_ptr| {
10881088 // After the first frame, start actually unwinding.
1089 it.* = if (SelfInfo != void and SelfInfo.can_unwind and fp_usability != .ideal)
1090 .{ .di = .init(context_ptr) }
1091 else
1092 .{ .fp = context_ptr.getFp() };
1089 if (SelfInfo != void and SelfInfo.can_unwind and fp_usability != .ideal) {
1090 it.* = .{ .di = .init(context_ptr) };
1091 } else {
1092 const fp = applyOffset(context_ptr.getFp(), stack_bias) orelse return .end;
1093 it.* = .{ .fp = fp };
1094 }
10931095
10941096 // The caller expects *return* addresses, where they will subtract 1 to find the address of the call.
10951097 // However, we have the actual current PC, which should not be adjusted. Compensate by adding 1.
......@@ -1099,7 +1101,7 @@ const StackIterator = union(enum) {
10991101 const di = getSelfDebugInfo() catch unreachable;
11001102 const ret_addr = di.unwindFrame(io, unwind_context) catch |err| {
11011103 const pc = unwind_context.pc;
1102 const fp = unwind_context.getFp();
1104 const fp = applyOffset(unwind_context.getFp(), stack_bias) orelse return .end;
11031105 unwind_context.deinit();
11041106 it.* = .{ .fp = fp };
11051107 return .{ .switch_to_fp = .{