authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-27 11:37:40-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-27 15:32:34-08:00
log1e188d790a028117440369e9638a436c0daf1b68
tree0d5ad9469ed90a065308f50963612a34c904c5af
parent15e73c70ab5d41395d2cc81e0737450eabcf49f9

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.

1 files changed, 1 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+1-1
......@@ -8278,7 +8278,6 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
82788278 return e;
82798279 },
82808280 };
8281 defer alertable_syscall.finish();
82828281 waitForApcOrAlert();
82838282 while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) {
82848283 alertable_syscall.checkCancel() catch |err| switch (err) {
......@@ -8289,6 +8288,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
82898288 };
82908289 waitForApcOrAlert();
82918290 }
8291 alertable_syscall.finish();
82928292 }
82938293 switch (io_status_block.u.Status) {
82948294 .SUCCESS, .END_OF_FILE, .PIPE_BROKEN => return io_status_block.Information,