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...@@ -8278,7 +8278,6 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8278 return e;8278 return e;
8279 },8279 },
8280 };8280 };
8281 defer alertable_syscall.finish();
8282 waitForApcOrAlert();8281 waitForApcOrAlert();
8283 while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) {8282 while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) {
8284 alertable_syscall.checkCancel() catch |err| switch (err) {8283 alertable_syscall.checkCancel() catch |err| switch (err) {
...@@ -8289,6 +8288,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8289,6 +8288,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8289 };8288 };
8290 waitForApcOrAlert();8289 waitForApcOrAlert();
8291 }8290 }
8291 alertable_syscall.finish();
8292 }8292 }
8293 switch (io_status_block.u.Status) {8293 switch (io_status_block.u.Status) {
8294 .SUCCESS, .END_OF_FILE, .PIPE_BROKEN => return io_status_block.Information,8294 .SUCCESS, .END_OF_FILE, .PIPE_BROKEN => return io_status_block.Information,