# build_runner: fix race condition in dispatch_deps capacity reservation · gitcafe/zig

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

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

Visibility: public

Requested revision: 6b9125cbe662d530160e0732c856aa0da86894c0

Requested commit: 6b9125cbe662d530160e0732c856aa0da86894c0

Commit: 6b9125cbe662d530160e0732c856aa0da86894c0

Tree: 7968821617128ab86b2b5e2d4d1081177c974942

Author: Doug Coleman

Committer: Doug Coleman

## Message

```
build_runner: fix race condition in dispatch_deps capacity reservation

Move ensureUnusedCapacity inside the mutex call to prevent
a race condition where other worker threads could append to
memory_blocked_steps between checking the length and iterating.

repro branch: https://codeberg.org/erg/zig/src/branch/fix-30014-repro
check out that branch, and depending on if you have the fix-30014 patch or not,
it will either race condition or succeed

Fixes #30014

```

## Parents

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

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