diff options
| author | Takeshi Yoneda <takeshi@tetrate.io> | 2021-08-09 14:39:26 +0900 |
|---|---|---|
| committer | Takeshi Yoneda <takeshi@tetrate.io> | 2021-08-09 14:39:26 +0900 |
| commit | 97560cd915008f04addc2c30af087aa89c162b02 (patch) | |
| tree | 8aed12c207ff84cc256a0c78955c23b61129ba22 /lib/std/debug.zig | |
| parent | 7814a2bd4a3ec22cd9548c622f7dc837dba968f7 (diff) | |
| parent | 799fedf612aa8742c446b015c12d21707a1dbec0 (diff) | |
| download | zig-97560cd915008f04addc2c30af087aa89c162b02.tar.gz zig-97560cd915008f04addc2c30af087aa89c162b02.zip | |
Merge remote-tracking branch 'origin' into libc-wasi-test
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index f74d0b3f91..c3ef9dec4c 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -438,7 +438,12 @@ pub fn writeCurrentStackTrace( } var it = StackIterator.init(start_addr, null); while (it.next()) |return_address| { - try printSourceAtAddress(debug_info, out_stream, return_address - 1, tty_config); + // On arm64 macOS, the address of the last frame is 0x0 rather than 0x1 as on x86_64 macOS, + // therefore, we do a check for `return_address == 0` before subtracting 1 from it to avoid + // an overflow. We do not need to signal `StackIterator` as it will correctly detect this + // condition on the subsequent iteration and return `null` thus terminating the loop. + const address = if (return_address == 0) return_address else return_address - 1; + try printSourceAtAddress(debug_info, out_stream, address, tty_config); } } |
