authorgravatar for zig-codeberg@jan-o-sch.netJan Schlien <zig-codeberg@jan-o-sch.net> 2026-10-09 10:39:47+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-10 09:10:00+02:00
log975d74f65474a9a73c007cf5dd4e1f19a7ccd25f
tree063492b90fc891d850be7828df31b54e4c15e05c
parentd1b5fac7f916745d90f0ec1718b347a36e45862a
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Io.Threaded: map EACCES from file reads

A read can fail with EACCES on a file that was opened successfully, e.g. procfs entries such as /proc/<pid>/stack check permissions at read time. The readv, preadv and pread switches did not handle it, so it ended up in unexpectedErrno which dumps a stack trace in Debug builds.

1 files changed, 3 insertions(+), 0 deletions(-)

lib/std/Io/Threaded.zig+3
...@@ -10008,6 +10008,7 @@ fn fileReadStreamingPosix(file: File, data: []const []u8) File.ReadStreamingErro...@@ -10008,6 +10008,7 @@ fn fileReadStreamingPosix(file: File, data: []const []u8) File.ReadStreamingErro
10008 if (native_os == .wasi) return error.IsDir; // File operation on directory.10008 if (native_os == .wasi) return error.IsDir; // File operation on directory.
10009 return error.NotOpenForReading;10009 return error.NotOpenForReading;
10010 },10010 },
10011 .ACCES => return syscall.fail(error.AccessDenied),
10011 .AGAIN => return syscall.fail(error.WouldBlock),10012 .AGAIN => return syscall.fail(error.WouldBlock),
10012 .IO => return syscall.fail(error.InputOutput),10013 .IO => return syscall.fail(error.InputOutput),
10013 .ISDIR => return syscall.fail(error.IsDir),10014 .ISDIR => return syscall.fail(error.IsDir),
...@@ -10186,6 +10187,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea...@@ -10186,6 +10187,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
10186 try syscall.checkCancel();10187 try syscall.checkCancel();
10187 continue;10188 continue;
10188 },10189 },
10190 .ACCES => return syscall.fail(error.AccessDenied),
10189 .NXIO => return syscall.fail(error.Unseekable),10191 .NXIO => return syscall.fail(error.Unseekable),
10190 .SPIPE => return syscall.fail(error.Unseekable),10192 .SPIPE => return syscall.fail(error.Unseekable),
10191 .OVERFLOW => return syscall.fail(error.Unseekable),10193 .OVERFLOW => return syscall.fail(error.Unseekable),
...@@ -10220,6 +10222,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea...@@ -10220,6 +10222,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
10220 try syscall.checkCancel();10222 try syscall.checkCancel();
10221 continue;10223 continue;
10222 },10224 },
10225 .ACCES => return syscall.fail(error.AccessDenied),
10223 .NXIO => return syscall.fail(error.Unseekable),10226 .NXIO => return syscall.fail(error.Unseekable),
10224 .SPIPE => return syscall.fail(error.Unseekable),10227 .SPIPE => return syscall.fail(error.Unseekable),
10225 .OVERFLOW => return syscall.fail(error.Unseekable),10228 .OVERFLOW => return syscall.fail(error.Unseekable),