authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-21 21:42:23-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-27 15:32:34-08:00
logc155ac50c25c871ea80f27688d2361a3a0bc24d6
treeb8c362629494a6b9e1f7f0f4d6758786d5e5c06f
parent7ab41bec2933ffb2ce136779fbc8c22c45df28a8

std.Io.Threaded: don't pass null to NtDelayExecution

Windows returns ACCESS_VIOLATION if you do that.

2 files changed, 4 insertions(+), 3 deletions(-)

lib/std/Io/Threaded.zig+3-2
...@@ -8301,6 +8301,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8301,6 +8301,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
83018301
8302 var io_status_block: windows.IO_STATUS_BLOCK = undefined;8302 var io_status_block: windows.IO_STATUS_BLOCK = undefined;
8303 var done: bool = false;8303 var done: bool = false;
8304 const infinite: windows.LARGE_INTEGER = windows.INFINITE;
83048305
8305 read: {8306 read: {
8306 const syscall: Syscall = try .start();8307 const syscall: Syscall = try .start();
...@@ -8329,7 +8330,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8329,7 +8330,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8329 }8330 }
8330 try syscall.toApc(.{ .handle = file.handle, .iosb = &io_status_block });8331 try syscall.toApc(.{ .handle = file.handle, .iosb = &io_status_block });
8331 while (true) {8332 while (true) {
8332 switch (windows.ntdll.NtDelayExecution(1, null)) {8333 switch (windows.ntdll.NtDelayExecution(1, &infinite)) {
8333 .USER_APC => {8334 .USER_APC => {
8334 if (!done) {8335 if (!done) {
8335 // Other APC work was queued before calling into this function.8336 // 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...@@ -8338,7 +8339,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8338 }8339 }
8339 break syscall.finishApc();8340 break syscall.finishApc();
8340 },8341 },
8341 .SUCCESS, .CANCELLED => {8342 .SUCCESS, .CANCELLED, .TIMEOUT, .ALERTED => {
8342 try syscall.checkCancelApc();8343 try syscall.checkCancelApc();
8343 continue;8344 continue;
8344 },8345 },
lib/std/os/windows/ntdll.zig+1-1
...@@ -591,7 +591,7 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(...@@ -591,7 +591,7 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(
591591
592pub extern "ntdll" fn NtDelayExecution(592pub extern "ntdll" fn NtDelayExecution(
593 Alertable: BOOLEAN,593 Alertable: BOOLEAN,
594 DelayInterval: ?*const LARGE_INTEGER,594 DelayInterval: *const LARGE_INTEGER,
595) callconv(.winapi) NTSTATUS;595) callconv(.winapi) NTSTATUS;
596596
597pub extern "ntdll" fn NtCancelIoFileEx(597pub extern "ntdll" fn NtCancelIoFileEx(