# std: check for overflow in dumpStackTraceFromBase · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/23e212a9d0b5cfdff991a40ca264f9d1284f0d5f)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 23e212a9d0b5cfdff991a40ca264f9d1284f0d5f

Requested commit: 23e212a9d0b5cfdff991a40ca264f9d1284f0d5f

Commit: 23e212a9d0b5cfdff991a40ca264f9d1284f0d5f

Tree: e53a70f813fb78130c7b5dfc08cef27f3b794aaf

Author: Xavier Bouchoux

Committer: Veikka Tuominen

## Message

```
std: check for overflow in dumpStackTraceFromBase

same change as [68e26a2ceea85a1] "std: check for overflow in writeCurrentStackTrace"

On arm64 macOS, the address of the last frame is 0x0 rather than
a positive value like 0x1 on x86_64 macOS, therefore, we overflow
an integer trying to subtract 1 when printing the stack trace. This
patch fixes it by first checking for this condition before trying
to subtract 1.

Same behaviour on i386-windows-msvc.

Note that we do not need to signal the `SignalIterator` about this
as it will correctly detect this condition on the subsequent iteration
and return `null`, thus terminating the loop.

```

## Parents

- [bd0dd225e843801b4b6162cbd2709c7325ab87b7](https://git.cafe/gitcafe/zig/commit/bd0dd225e843801b4b6162cbd2709c7325ab87b7?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/23e212a9d0b5cfdff991a40ca264f9d1284f0d5f?format=markdown)
