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-30 12:10:01-08:00
log84303546ba603623070932432efb43c413d48a0e
treef95e20d9f135e5d7b1c5244011c725df6ffea83f
parent36940c39539e5d4d8a39ceaed035f213b3902c92

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
...@@ -8444,6 +8444,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8444,6 +8444,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
84448444
8445 var io_status_block: windows.IO_STATUS_BLOCK = undefined;8445 var io_status_block: windows.IO_STATUS_BLOCK = undefined;
8446 var done: bool = false;8446 var done: bool = false;
8447 const infinite: windows.LARGE_INTEGER = windows.INFINITE;
84478448
8448 read: {8449 read: {
8449 const syscall: Syscall = try .start();8450 const syscall: Syscall = try .start();
...@@ -8472,7 +8473,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8472,7 +8473,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8472 }8473 }
8473 try syscall.toApc(.{ .handle = file.handle, .iosb = &io_status_block });8474 try syscall.toApc(.{ .handle = file.handle, .iosb = &io_status_block });
8474 while (true) {8475 while (true) {
8475 switch (windows.ntdll.NtDelayExecution(1, null)) {8476 switch (windows.ntdll.NtDelayExecution(1, &infinite)) {
8476 .USER_APC => {8477 .USER_APC => {
8477 if (!done) {8478 if (!done) {
8478 // Other APC work was queued before calling into this function.8479 // Other APC work was queued before calling into this function.
...@@ -8481,7 +8482,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8481,7 +8482,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8481 }8482 }
8482 break syscall.finishApc();8483 break syscall.finishApc();
8483 },8484 },
8484 .SUCCESS, .CANCELLED => {8485 .SUCCESS, .CANCELLED, .TIMEOUT, .ALERTED => {
8485 try syscall.checkCancelApc();8486 try syscall.checkCancelApc();
8486 continue;8487 continue;
8487 },8488 },
lib/std/os/windows/ntdll.zig+1-1
...@@ -596,7 +596,7 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(...@@ -596,7 +596,7 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(
596596
597pub extern "ntdll" fn NtDelayExecution(597pub extern "ntdll" fn NtDelayExecution(
598 Alertable: BOOLEAN,598 Alertable: BOOLEAN,
599 DelayInterval: ?*const LARGE_INTEGER,599 DelayInterval: *const LARGE_INTEGER,
600) callconv(.winapi) NTSTATUS;600) callconv(.winapi) NTSTATUS;
601601
602pub extern "ntdll" fn NtCancelIoFileEx(602pub extern "ntdll" fn NtCancelIoFileEx(