| ... | ... | @@ -187,7 +187,13 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { |
| 187 | 187 | printSourceAtAddress(debug_info, stderr, ip, tty_config) catch return; |
| 188 | 188 | var it = StackIterator.init(null, bp); |
| 189 | 189 | while (it.next()) |return_address| { |
| 190 | | printSourceAtAddress(debug_info, stderr, return_address - 1, tty_config) catch return; |
| 190 | // On arm64 macOS, the address of the last frame is 0x0 rather than 0x1 as on x86_64 macOS, |
| 191 | // therefore, we do a check for `return_address == 0` before subtracting 1 from it to avoid |
| 192 | // an overflow. We do not need to signal `StackIterator` as it will correctly detect this |
| 193 | // condition on the subsequent iteration and return `null` thus terminating the loop. |
| 194 | // same behaviour for i386-windows-msvc |
| 195 | const address = if (return_address == 0) return_address else return_address - 1; |
| 196 | printSourceAtAddress(debug_info, stderr, address, tty_config) catch return; |
| 191 | 197 | } |
| 192 | 198 | } |
| 193 | 199 | } |
| ... | ... | @@ -563,6 +569,7 @@ pub fn writeCurrentStackTrace( |
| 563 | 569 | // therefore, we do a check for `return_address == 0` before subtracting 1 from it to avoid |
| 564 | 570 | // an overflow. We do not need to signal `StackIterator` as it will correctly detect this |
| 565 | 571 | // condition on the subsequent iteration and return `null` thus terminating the loop. |
| 572 | // same behaviour for i386-windows-msvc |
| 566 | 573 | const address = if (return_address == 0) return_address else return_address - 1; |
| 567 | 574 | try printSourceAtAddress(debug_info, out_stream, address, tty_config); |
| 568 | 575 | } |