authorgravatar for ypsvlq@gmail.comElaine Gibson <ypsvlq@gmail.com> 2026-08-01 22:43:06+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-02 12:04:20+02:00
log12dc2f261166fe901ed955a1e87fcf292e3b1b86
tree5f8ed6ba6d694ded540865660b850175f8dd6f0e
parent833105128485bf84a22f26506eb5e7b9bfa146a0

std: pass null for infinite NtWaitForSingleObject timeout

fixes #31954

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

lib/std/Io/Threaded.zig+2-4
...@@ -15347,8 +15347,7 @@ fn childKillWindows(t: *Threaded, child: *process.Child, exit_code: windows.UINT...@@ -15347,8 +15347,7 @@ fn childKillWindows(t: *Threaded, child: *process.Child, exit_code: windows.UINT
15347 _ = windows.ntdll.RtlReportSilentProcessExit(handle, @fromBackingInt(@intCast(exit_code)));15347 _ = windows.ntdll.RtlReportSilentProcessExit(handle, @fromBackingInt(@intCast(exit_code)));
15348 switch (windows.ntdll.NtTerminateProcess(handle, @fromBackingInt(@intCast(exit_code)))) {15348 switch (windows.ntdll.NtTerminateProcess(handle, @fromBackingInt(@intCast(exit_code)))) {
15349 .SUCCESS, .PROCESS_IS_TERMINATING => {15349 .SUCCESS, .PROCESS_IS_TERMINATING => {
15350 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);15350 _ = windows.ntdll.NtWaitForSingleObject(handle, .FALSE, null);
15351 _ = windows.ntdll.NtWaitForSingleObject(handle, .FALSE, &infinite_timeout);
15352 childCleanupWindows(child);15351 childCleanupWindows(child);
15353 },15352 },
15354 .ACCESS_DENIED => {15353 .ACCESS_DENIED => {
...@@ -15371,8 +15370,7 @@ fn childWaitWindows(child: *process.Child) process.Child.WaitError!process.Child...@@ -15371,8 +15370,7 @@ fn childWaitWindows(child: *process.Child) process.Child.WaitError!process.Child
15371 const handle = child.id.?;15370 const handle = child.id.?;
1537215371
15373 const alertable_syscall: AlertableSyscall = try .start();15372 const alertable_syscall: AlertableSyscall = try .start();
15374 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);15373 while (true) switch (windows.ntdll.NtWaitForSingleObject(handle, .TRUE, null)) {
15375 while (true) switch (windows.ntdll.NtWaitForSingleObject(handle, .TRUE, &infinite_timeout)) {
15376 windows.NTSTATUS.WAIT_0 => break alertable_syscall.finish(),15374 windows.NTSTATUS.WAIT_0 => break alertable_syscall.finish(),
15377 .USER_APC, .ALERTED, .TIMEOUT => {15375 .USER_APC, .ALERTED, .TIMEOUT => {
15378 try alertable_syscall.checkCancel();15376 try alertable_syscall.checkCancel();
lib/std/Thread.zig+1-2
...@@ -639,8 +639,7 @@ const WindowsThreadImpl = struct {...@@ -639,8 +639,7 @@ const WindowsThreadImpl = struct {
639 }639 }
640640
641 fn join(self: Impl) void {641 fn join(self: Impl) void {
642 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);642 switch (windows.ntdll.NtWaitForSingleObject(self.thread.thread_handle, .FALSE, null)) {
643 switch (windows.ntdll.NtWaitForSingleObject(self.thread.thread_handle, .FALSE, &infinite_timeout)) {
644 windows.NTSTATUS.WAIT_0 => {},643 windows.NTSTATUS.WAIT_0 => {},
645 else => |status| windows.unexpectedStatus(status) catch unreachable,644 else => |status| windows.unexpectedStatus(status) catch unreachable,
646 }645 }
test/standalone/windows_argv/fuzz.zig+1-2
...@@ -147,8 +147,7 @@ fn spawnVerify(verify_path: [:0]const u16, cmd_line: [:0]const u16) !windows.DWO...@@ -147,8 +147,7 @@ fn spawnVerify(verify_path: [:0]const u16, cmd_line: [:0]const u16) !windows.DWO
147 break :spawn proc_info.hProcess;147 break :spawn proc_info.hProcess;
148 };148 };
149 defer windows.CloseHandle(child_proc);149 defer windows.CloseHandle(child_proc);
150 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);150 switch (windows.ntdll.NtWaitForSingleObject(child_proc, .FALSE, null)) {
151 switch (windows.ntdll.NtWaitForSingleObject(child_proc, .FALSE, &infinite_timeout)) {
152 windows.NTSTATUS.WAIT_0 => {},151 windows.NTSTATUS.WAIT_0 => {},
153 .TIMEOUT => return error.WaitTimeOut,152 .TIMEOUT => return error.WaitTimeOut,
154 else => |status| return windows.unexpectedStatus(status),153 else => |status| return windows.unexpectedStatus(status),