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

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

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

Visibility: public

Requested revision: 68e26a2ceea85a149cb23286504cbdcec1ae814e

Requested commit: 68e26a2ceea85a149cb23286504cbdcec1ae814e

Commit: 68e26a2ceea85a149cb23286504cbdcec1ae814e

Tree: 7d7baf8c489b53b21df872efd3c10463b29ab65e

Author: Jakub Konka

Committer: Andrew Kelley

## Message

```
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.

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

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

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