authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-20 03:44:51+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-23 19:34:02+02:00
logc13355abda21e90443ae9ea59706e491111a8bcb
tree2a913790f3d669bbdfcce35267904333a996e025
parenta689c3819777c7ebbf00f752951a9a69c7a44c8e
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug: fix FP unwind progress check for stackGrowth() == .up targets


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

lib/std/debug.zig+7-3
...@@ -974,11 +974,15 @@ const StackIterator = union(enum) {...@@ -974,11 +974,15 @@ const StackIterator = union(enum) {
974 const ra_ptr: *const usize = @ptrFromInt(ra_addr);974 const ra_ptr: *const usize = @ptrFromInt(ra_addr);
975 const bp = applyOffset(bp_ptr.*, stack_bias) orelse return .end;975 const bp = applyOffset(bp_ptr.*, stack_bias) orelse return .end;
976976
977 // The stack grows downards, so `bp > fp` should always hold. If it doesn't, this977 // If the stack grows downwards, `bp > fp` should always hold; conversely, if it
978 // frame is invalid, so we'll treat it as though it we reached end of stack. The978 // grows upwards, `bp < fp` should always hold. If that is not the case, this
979 // frame is invalid, so we'll treat it as though we reached end of stack. The
979 // exception is address 0, which is a graceful end-of-stack signal, in which case980 // exception is address 0, which is a graceful end-of-stack signal, in which case
980 // *this* return address is valid and the *next* iteration will be the last.981 // *this* return address is valid and the *next* iteration will be the last.
981 if (bp != 0 and bp <= fp) return .end;982 if (bp != 0 and switch (comptime builtin.target.stackGrowth()) {
983 .down => bp <= fp,
984 .up => bp >= fp,
985 }) return .end;
982986
983 it.fp = bp;987 it.fp = bp;
984 const ra = stripInstructionPtrAuthCode(ra_ptr.*);988 const ra = stripInstructionPtrAuthCode(ra_ptr.*);