Zig Version
0.16.0
Steps to Reproduce and Observed Behavior
This happened one of our contributor's computer when compiling Cubyz:
info: Downloading cubyz_deps libraries cubyz_deps_x86_64_linux.
info: Downloading cubyz_test_runner dependency.
thread 691876 panic: programmer bug caused syscall error: INVAL
error return context:
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Threaded.zig:4092:31: 0x1297211 in dirAccessPosix (std.zig)
.NOENT => return error.FileNotFound,
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Dir.zig:439:5: 0x13bff6b in access (std.zig)
return io.vtable.dirAccess(io.userdata, dir, sub_path, options);
^
stack trace:
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Threaded.zig:14055:34: 0x124565a in errnoBug (std.zig)
if (is_debug) std.debug.panic("programmer bug caused syscall error: {t}", .{err});
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Threaded.zig:1440:33: 0x12561b8 in errnoBug (std.zig)
return Threaded.errnoBug(err);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Threaded.zig:7613:48: 0x128b3f9 in dirRenamePreserveLinux (std.zig)
.INVAL => |err| return syscall.errnoBug(err),
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Threaded.zig:7377:59: 0x128a478 in dirRenamePreserve (std.zig)
if (native_os == .linux) return dirRenamePreserveLinux(old_dir, old_sub_path, new_dir, new_sub_path);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Dir.zig:1140:39: 0x14b170b in renamePreserve (std.zig)
return io.vtable.dirRenamePreserve(io.userdata, old_dir, old_sub_path, new_dir, new_sub_path);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/File/Atomic.zig:55:34: 0x14b0e6f in link (std.zig)
try af.dir.renamePreserve(&tmp_sub_path, af.dir, af.dest_sub_path, io);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Build/Step/Options.zig:493:29: 0x1a5dd6a in make (std.zig)
atomic_file.link(io) catch |err| switch (err) {
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Build/Step.zig:278:33: 0x14eb62f in make (std.zig)
const make_result = s.makeFn(s, options);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/compiler/build_runner.zig:1345:26: 0x14e966e in makeStep (build_runner.zig)
} else if (s.make(.{
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io.zig:1245:17: 0x14e9295 in start (std.zig)
_ = @as(Cancelable!void, @call(.auto, function, args_casted.*)) catch {};
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Threaded.zig:552:22: 0x12a99d5 in start (std.zig)
task.func(task.contextPointer());
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Io/Threaded.zig:1797:29: 0x12a7bd4 in worker (std.zig)
runnable.startFn(runnable, &thread, t);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Thread.zig:422:13: 0x12a78b5 in callFn__anon_27824 (std.zig)
@call(.auto, f, args);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/Thread.zig:1431:30: 0x12a7670 in entryFn (std.zig)
return callFn(f, self.fn_args);
^
/home/uni/cubyz/master/Cubyz/compiler/zig/lib/std/os/linux/x86_64.zig:105:5: 0x12a77d5 in clone (std.zig)
asm volatile (
^
From what we've gathered:
- It fails while trying to create the
options.zigfail from our custom build options as created fromb.addOptions - the error is
EINVALinrenameat2, which is called during the renaming step of the atomic file. In the location we could find a file with a random name and the expected contents that was presumably supposed to be renamed tooptions.zigfor atomic access. - the error occurs on Linux Mint Cinnamon 21.3 on both Linux Kernel 5.15 and 6.8
- the error does not occur on my own computer which uses Linux Mint MATE 21.2 + Kernel 6.8
- the error is repeatable, and happens every time
We managed to find a workaround, by manually renaming the file in question to options.zig in the cache, then it would not try to do the atomic renaming anymore.
Expected Behavior
The options step should not fail on ordinary systems.