Host test failure in core/direct_io.zig on Linux kernel 6.17: O_DIRECT open succeeds on procfs, so the test's 'plain' fd is not plain
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- linux
- Domain
- operating-systems, testing
Research direction
The failing test is 'direct reads return the same bytes as buffered reads' in zig/src/core/direct_io.zig, around lines 86-100, where the comparison fd is opened with File.open and its direct flag is then flipped. Run zig build test on Linux to reproduce the -1 from the pread of 1 byte at offset 0. Done when the comparison fd is opened without O_DIRECT, the test passes on kernel 6.17, and the test no longer depends on procfs rejecting O_DIRECT at open.
Written by the indexing model from the issue text.
Description
What fails
At v1.0.2 (f8fe17d), one host test fails on a DGX Spark head (aarch64, Ubuntu 24.04, kernel
6.17.0-1032-nvidia):
zig build test
...
error: 'direct_io.test.direct reads return the same bytes as buffered reads' failed:
expected 1, found -1
zig/src/core/direct_io.zig:100:9 in test.direct reads return the same bytes as buffered reads
try std.testing.expectEqual(@as(isize, @intCast(c[1])), n);
75/76 pass; this is the only failure.
Cause
The test's comparison fd is not actually a plain fd. File.open tries O_DIRECT first and falls
back only when the open fails. On this kernel, open("/proc/self/exe", O_DIRECT) succeeds
(procfs tolerates the flag at open time), so both fds in the test are O_DIRECT. The test then sets
only the struct flag (plain.direct = false), which does not change the fd, and the first
comparison read — an unaligned pread(fd, want.ptr, 1, 0) — returns -1 with EINVAL.
Minimal C repro on the same host:
open O_DIRECT: 3 errno=none
pread aligned 4096@0: 4096 errno=none
pread 1@0: -1 errno=Invalid argument
The engine is unaffected: checkpoints are real NVMe files, and the fallback covers filesystems that
refuse O_DIRECT at open. The latent assumption is only that an O_DIRECT open of a procfs file
fails, which held on older kernels and not on 6.17.
Proposed fix (test-only)
Open the comparison fd explicitly without O_DIRECT, so the test no longer depends on the kernel's
procfs behavior:
--- a/zig/src/core/direct_io.zig
+++ b/zig/src/core/direct_io.zig
@@ -86,9 +86,10 @@
if (builtin.os.tag != .linux) return error.SkipZigTest;
const gpa = std.testing.allocator;
var f = try File.open("/proc/self/exe");
defer f.close();
- var plain = try File.open("/proc/self/exe");
- defer plain.close();
- plain.direct = false;
+ const plain_fd = std.c.open("/proc/self/exe", .{ .ACCMODE = .RDONLY, .CLOEXEC = true });
+ if (plain_fd < 0) return error.FileNotFound;
+ var plain = File{ .fd = plain_fd, .direct = false };
+ defer plain.close();
I'll send this as a one-commit pull request if that's the preferred path.
— Gustav (GustavBlack)
- Dominant language
- Python
- Stars
- 995
- Forks
- 169
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 446
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ashhart/TensorFold
-
Test the computer-use key table and request parser on LinuxPossibly taken @AdrianBinDC claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 20/100
ashhart/TensorFold#2217 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ashhart/TensorFold#2192 · 1 comment ·
Maintainers usually reply within 1 day
-
GLM on CUDA: a kept prompt state carries the dead half of the double-buffered KDA state (71 MB a rank)Possibly taken @volfco claimed this 1 day ago. Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
ashhart/TensorFold#2180 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ashhart/TensorFold#2171 · 1 comment ·
Maintainers usually reply within 1 day
-
llama --drafter: a request that stands aside never re-measures, its probes are spent on the look-ahead askPossibly taken @BobClawblaw claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ashhart/TensorFold#2168 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ashhart/TensorFold
Similar issues
-
follow-up needs-triage S3: minor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manaflow-ai/cmux#36856 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation good first issue help wanted
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Shell framework build fails at "copy the shader libraries": the iOS shader libraries are now one file b-<chain>.imgPossibly taken @xiaofeng-han claimed this today. Openbuild ios
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day