From ab1268efc33aa94854d7fb7aa312a079ded0706d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 27 Jan 2026 11:33:07 -0800 Subject: [PATCH] std.Io.Threaded: fix bad use of AlertableSyscall The defer would cause 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 0a17e58a67..0f0b043ce0 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -8689,7 +8689,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) { @@ -8700,6 +8699,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us }; waitForApcOrAlert(); } + alertable_syscall.finish(); }, } else |err| return err; return ntReadFileResult(&io_status_block);