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 andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-10 02:02:30+02:00
log3f3e88e7b455bb458839d0d59eb4c50699aeadbf
tree99cd67266e395543eb59ab338c52b81466b93b69
parent30411c1a5fc8947aa6d430713371cfd77f05285a

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
...@@ -10030,6 +10030,7 @@ fn fileReadStreamingPosix(file: File, data: []const []u8) File.ReadStreamingErro...@@ -10030,6 +10030,7 @@ fn fileReadStreamingPosix(file: File, data: []const []u8) File.ReadStreamingErro
10030 if (native_os == .wasi) return error.IsDir; // File operation on directory.10030 if (native_os == .wasi) return error.IsDir; // File operation on directory.
10031 return error.NotOpenForReading;10031 return error.NotOpenForReading;
10032 },10032 },
10033 .ACCES => return syscall.fail(error.AccessDenied),
10033 .AGAIN => return syscall.fail(error.WouldBlock),10034 .AGAIN => return syscall.fail(error.WouldBlock),
10034 .IO => return syscall.fail(error.InputOutput),10035 .IO => return syscall.fail(error.InputOutput),
10035 .ISDIR => return syscall.fail(error.IsDir),10036 .ISDIR => return syscall.fail(error.IsDir),
...@@ -10208,6 +10209,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea...@@ -10208,6 +10209,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
10208 try syscall.checkCancel();10209 try syscall.checkCancel();
10209 continue;10210 continue;
10210 },10211 },
10212 .ACCES => return syscall.fail(error.AccessDenied),
10211 .NXIO => return syscall.fail(error.Unseekable),10213 .NXIO => return syscall.fail(error.Unseekable),
10212 .SPIPE => return syscall.fail(error.Unseekable),10214 .SPIPE => return syscall.fail(error.Unseekable),
10213 .OVERFLOW => return syscall.fail(error.Unseekable),10215 .OVERFLOW => return syscall.fail(error.Unseekable),
...@@ -10242,6 +10244,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea...@@ -10242,6 +10244,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
10242 try syscall.checkCancel();10244 try syscall.checkCancel();
10243 continue;10245 continue;
10244 },10246 },
10247 .ACCES => return syscall.fail(error.AccessDenied),
10245 .NXIO => return syscall.fail(error.Unseekable),10248 .NXIO => return syscall.fail(error.Unseekable),
10246 .SPIPE => return syscall.fail(error.Unseekable),10249 .SPIPE => return syscall.fail(error.Unseekable),
10247 .OVERFLOW => return syscall.fail(error.Unseekable),10250 .OVERFLOW => return syscall.fail(error.Unseekable),