From c155ac50c25c871ea80f27688d2361a3a0bc24d6 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 21 Jan 2026 21:42:23 -0800 Subject: [PATCH] std.Io.Threaded: don't pass null to NtDelayExecution Windows returns ACCESS_VIOLATION if you do that. --- lib/std/Io/Threaded.zig | 5 +++-- lib/std/os/windows/ntdll.zig | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 7d1ad99231aacbf81d349ede9b85d25d9b35bcca..96a5d648eedfec47b31715d804c3e424cc76d3de 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -8301,6 +8301,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us var io_status_block: windows.IO_STATUS_BLOCK = undefined; var done: bool = false; + const infinite: windows.LARGE_INTEGER = windows.INFINITE; read: { const syscall: Syscall = try .start(); @@ -8329,7 +8330,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us } try syscall.toApc(.{ .handle = file.handle, .iosb = &io_status_block }); while (true) { - switch (windows.ntdll.NtDelayExecution(1, null)) { + switch (windows.ntdll.NtDelayExecution(1, &infinite)) { .USER_APC => { if (!done) { // Other APC work was queued before calling into this function. @@ -8338,7 +8339,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us } break syscall.finishApc(); }, - .SUCCESS, .CANCELLED => { + .SUCCESS, .CANCELLED, .TIMEOUT, .ALERTED => { try syscall.checkCancelApc(); continue; }, diff --git a/lib/std/os/windows/ntdll.zig b/lib/std/os/windows/ntdll.zig index ce70cb0f37547231370e580950f4d338bf05cf00..c9d9b5ef0ebe5709046de05bf2ea4ea770e3b7a0 100644 --- a/lib/std/os/windows/ntdll.zig +++ b/lib/std/os/windows/ntdll.zig @@ -591,7 +591,7 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile( pub extern "ntdll" fn NtDelayExecution( Alertable: BOOLEAN, - DelayInterval: ?*const LARGE_INTEGER, + DelayInterval: *const LARGE_INTEGER, ) callconv(.winapi) NTSTATUS; pub extern "ntdll" fn NtCancelIoFileEx( -- 2.54.0