From 1e188d790a028117440369e9638a436c0daf1b68 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 27 Jan 2026 11:37:40 -0800 Subject: [PATCH] std.Io.Threaded: fix bad use of AlertableSyscall The defer causes two problems: 1. keeping the state active during call to NtCancelIoFile 2. invalid state transition. after canceled is returned from checkCancel, new status is already canceled. calling finish after that is illegal. --- lib/std/Io/Threaded.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 2263c0b4503a60e2ccd6c0dca6404cf8421120cb..bd6e4db4c266acb2348283e263588f8a43d8ea92 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -8278,7 +8278,6 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us return e; }, }; - defer alertable_syscall.finish(); waitForApcOrAlert(); while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) { alertable_syscall.checkCancel() catch |err| switch (err) { @@ -8289,6 +8288,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us }; waitForApcOrAlert(); } + alertable_syscall.finish(); } switch (io_status_block.u.Status) { .SUCCESS, .END_OF_FILE, .PIPE_BROKEN => return io_status_block.Information, -- 2.54.0