zig icon indicating copy to clipboard operation
zig copied to clipboard

zig build --watch crashes

Open tadeohepperle opened this issue 1 month ago • 5 comments

Zig Version

0.15.1

6.1.126-1-MANJARO x86_64

Steps to Reproduce and Observed Behavior

Seems similar to https://github.com/ziglang/zig/issues/22800 but still happens at version 0.15.1 for me. I just did zig init followed by zig build --watch and get the following output:

[tadeo@tadeo fzig]$ zig build --watch

Build Summary: 3/3 steps succeeded
install success
└─ install fzig success

thread 2239656 panic: reached unreachable code
/home/tadeo/.zvm/0.15.1/lib/std/posix.zig:7282:19: 0x12136fa in name_to_handle_atZ (std.zig)
        .INVAL => unreachable, // bad flags, or handle_bytes too big
                  ^
/home/tadeo/.zvm/0.15.1/lib/std/posix.zig:7269:30: 0x11e0465 in name_to_handle_at (std.zig)
    return name_to_handle_atZ(dirfd, &pathname_c, handle, mount_id, flags);
                             ^
/home/tadeo/.zvm/0.15.1/lib/std/Build/Watch.zig:125:40: 0x11ac5c4 in getDirHandle (std.zig)
            try posix.name_to_handle_at(path.root_dir.handle.fd, adjusted_path, stack_ptr, mount_id, std.os.linux.AT.HANDLE_FID);
                                       ^
/home/tadeo/.zvm/0.15.1/lib/std/Build/Watch.zig:180:63: 0x11acba2 in update (std.zig)
                            const dir_handle = Os.getDirHandle(gpa, path, &mount_id) catch |err| switch (err) {
                                                              ^
/home/tadeo/.zvm/0.15.1/lib/std/Build/Watch.zig:910:21: 0x11aee7e in update (std.zig)
    return Os.update(w, gpa, steps);
                    ^
/home/tadeo/.zvm/0.15.1/lib/compiler/build_runner.zig:511:21: 0x11b9891 in main (build_runner.zig)
        try w.update(gpa, run.step_stack.keys());
                    ^
/home/tadeo/.zvm/0.15.1/lib/std/start.zig:627:37: 0x11bdc49 in posixCallMainAndExit (std.zig)
            const result = root.main() catch |err| {
                                    ^
/home/tadeo/.zvm/0.15.1/lib/std/start.zig:232:5: 0x119c331 in _start (std.zig)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x0 in ??? (???)
error: the following build command crashed:
.zig-cache/o/e78a600225040bd97100491d2642b120/build /home/tadeo/.zvm/0.15.1/zig /home/tadeo/.zvm/0.15.1/lib /home/tadeo/code/test/fzig .zig-cache /home/tadeo/.cache/zig --seed 0xa5a49956 -Ze65bd621bb52669e --watch

Expected Behavior

Expected this to not crash

tadeohepperle avatar Oct 09 '25 22:10 tadeohepperle

uname -mr?

alexrp avatar Oct 09 '25 22:10 alexrp

uname -mr?

6.1.126-1-MANJARO x86_64

tadeohepperle avatar Oct 09 '25 22:10 tadeohepperle

The AT_HANDLE_FID flag requires Linux kernel 6.5+. We support 5.10+: https://ziglang.org/download/0.15.1/release-notes.html#OS-Version-Requirements

I'm not sure if there's a meaningful fallback we can do here though.

alexrp avatar Oct 09 '25 23:10 alexrp

Two notes:

  1. I have a partial solution to https://github.com/ziglang/zig/issues/6389 in my std.Io branch that I've been plugging away at.
  2. I don't think we'll make an attempt to support --watch without AT_HANDLE_FD. It's too good, not worth supporting hacky code for older kernels. This issue is tracking the fact that it crashes rather than exiting with a helpful failure message.

andrewrk avatar Oct 09 '25 23:10 andrewrk

  1. I don't think we'll make an attempt to support --watch without AT_HANDLE_FD. It's too good, not worth supporting hacky code for older kernels. This issue is tracking the fact that it crashes rather than exiting with a helpful failure message.

Like @alexrp pointed out - this was added in Linux 6.5 which was released only two years ago. I personally encountered this issue because I was running a VM that had a base Bookworm installation (Kernel 6.1) - which has a LTS date for like another ten years! I totally get not supporting super old, antiquated kernels, but I feel like the reliance on this relatively new kernel feature is impacting a non-zero amount of developers.

Any chance the project would be open to someone else implementing an alternative support path?

CuckooEXE avatar Nov 07 '25 12:11 CuckooEXE