# std: do not call malloc\(\) between fork\(\) and execv\(\) · gitcafe/zig

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

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

Visibility: public

Requested revision: 3f9588ca29c721f11eb9dae8f6de8ebd1155c7bf

Requested commit: 3f9588ca29c721f11eb9dae8f6de8ebd1155c7bf

Commit: 3f9588ca29c721f11eb9dae8f6de8ebd1155c7bf

Tree: cef7fd69c3dc20dabdda4f90d3a7fc5b2c46d13f

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std: do not call malloc() between fork() and execv()

We were violating the POSIX standard which resulted in a deadlock on
musl v1.1.24 on aarch64 alpine linux, uncovered with the new ThreadPool
usage in the stage2 compiler.

std.os execv functions that accept an Allocator parameter are removed
because they are footguns. The POSIX standard does not allow calls to
malloc() between fork() and execv() and since it is common to both
(1) call execv() after fork() and (2) use std.heap.c_allocator,
Programmers are encouraged to go through the `std.process` API
instead, causing some dissonance when combined with `std.os` APIs.

I also slapped a big warning message on all the relevant doc comments.

```

## Parents

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

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