# std.Thread: mask all signals before unmapping stack · gitcafe/zig

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

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

Visibility: public

Requested revision: 073ef0f393ff4297e8d48a72f30a605c2d272289

Requested commit: 073ef0f393ff4297e8d48a72f30a605c2d272289

Commit: 073ef0f393ff4297e8d48a72f30a605c2d272289

Tree: fd179193b6bd11d0eb981f3add5923f9fca3a22f

Author: Matthew Lugg

Committer: Matthew Lugg

## Message

```
std.Thread: mask all signals before unmapping stack

As the comment explains, if a signal were to arrive between a detached
thread's `munmap` and `exit` calls, the signal handler would immediately
trigger SIGSEGV due to the stack being unmapped. To solve this, we need
to block all signals before entering this logic. The musl implementation
which this logic was ported from does this exact thing; that logic was
just lost when porting.

Notably, this would lead to a crash with no stack trace, because the
SIGSEGV handler would itself crash due to the missing stack.

```

## Parents

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

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