diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-20 03:44:51 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-23 19:34:02 +0200 |
| commit | c13355abda21e90443ae9ea59706e491111a8bcb (patch) | |
| tree | 2a913790f3d669bbdfcce35267904333a996e025 /lib/std/debug.zig | |
| parent | a689c3819777c7ebbf00f752951a9a69c7a44c8e (diff) | |
| download | zig-c13355abda21e90443ae9ea59706e491111a8bcb.tar.gz zig-c13355abda21e90443ae9ea59706e491111a8bcb.zip | |
std.debug: fix FP unwind progress check for stackGrowth() == .up targets
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 9a0a1f27d9..677630fbcf 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -974,11 +974,15 @@ const StackIterator = union(enum) { const ra_ptr: *const usize = @ptrFromInt(ra_addr); const bp = applyOffset(bp_ptr.*, stack_bias) orelse return .end; - // The stack grows downards, so `bp > fp` should always hold. If it doesn't, this - // frame is invalid, so we'll treat it as though it we reached end of stack. The + // If the stack grows downwards, `bp > fp` should always hold; conversely, if it + // grows upwards, `bp < fp` should always hold. If that is not the case, this + // frame is invalid, so we'll treat it as though we reached end of stack. The // exception is address 0, which is a graceful end-of-stack signal, in which case // *this* return address is valid and the *next* iteration will be the last. - if (bp != 0 and bp <= fp) return .end; + if (bp != 0 and switch (comptime builtin.target.stackGrowth()) { + .down => bp <= fp, + .up => bp >= fp, + }) return .end; it.fp = bp; const ra = stripInstructionPtrAuthCode(ra_ptr.*); |
