Panic on multiple zig build runs

Zig version: 0.13.0-dev.211+6a65561e3
OS: macOS Sonoma 14.4.1 (M1 Mac)

Pristine zig init project. If you try to run zig build run more than once, you get a panic. If I delete zig-cache, I can run it again.

❯ zig build run
All your codebase are belong to us.
Run `zig build test` to run the tests.

❯ zig build run
All your codebase are belong to us.
Run `zig build test` to run the tests.
thread 5419594 panic: reached unreachable code
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/debug.zig:403:14: 0x104dde337 in assert (build)
    if (!ok) unreachable; // assertion failure
             ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Build/Cache.zig:896:15: 0x104f14a63 in writeManifest (build)
        assert(self.have_exclusive_lock);
              ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Build/Step.zig:554:26: 0x104f153d3 in writeManifest (build)
        man.writeManifest() catch |err| {
                         ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Build/Step/Run.zig:713:31: 0x104eb990b in make (build)
        try step.writeManifest(&man);
                              ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Build/Step.zig:182:13: 0x104e5596f in make (build)
    s.makeFn(s, prog_node) catch |err| switch (err) {
            ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/compiler/build_runner.zig:948:31: 0x104e1af83 in workerMakeOneStep (build)
    const make_result = s.make(&sub_prog_node);
                              ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Thread/Pool.zig:102:39: 0x104e1b8ef in runFn (build)
            @call(.auto, func, closure.arguments);
                                      ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Thread/Pool.zig:191:18: 0x104e7c9d3 in worker (build)
            runFn(&run_node.data);
                 ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Thread.zig:408:13: 0x104e541bb in callFn__anon_14051 (build)
            @call(.auto, f, args);
            ^
/Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/lib/std/Thread.zig:674:30: 0x104e1a79b in entryFn (build)
                return callFn(f, args_ptr.*);
                             ^
???:?:?: 0x196c62f93 in ??? (libsystem_pthread.dylib)
???:?:?: 0xa549000196c5dd33 in ??? (???)
error: the following build command crashed:
/Users/jecolon/code/zig/bar/zig-cache/o/23d675102f29e840295a509e95c1dc7c/build /Users/jecolon/Downloads/zig-macos-aarch64-0.13.0-dev.211+6a65561e3/zig /Users/jecolon/code/zig/bar /Users/jecolon/code/zig/bar/zig-cache /Users/jecolon/.cache/zig --seed 0xe31685a8 -Zcc6aaeb301479d08 run
3 Likes

Same behavior on Debian 12 (Debian 6.1.85-1 (2024-04-11) x86_64 GNU/Linu) .

Same situation for me with zig 0.13.0-dev.211+6a65561e3 and Fedora Linux 39 (6.8.8-200.fc39.x86_64).

However, same code run as expected with zig 0.12.0, so I think it is only a temporary situation.

Can confirm, I have the same issue running the same version on arch linux.

Strangely, it only occurs when when I repeat the command with the same arguments passed on to the process. With zig build run -- new args it doesn’t crash.

Didn’t find an exact match, so filed a new issue: Panic on multiple zig build runs · Issue #20015 · ziglang/zig · GitHub

2 Likes

Builder picked the commit that fixes this and builds tarballs for 0.13.0-dev.217+ad7217229
ETA 4-5h from now

3 Likes