authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-27 11:33:07-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-30 12:10:01-08:00
logab1268efc33aa94854d7fb7aa312a079ded0706d
tree3b5026607b310a570c76583cdac160a756038780
parent8a985236af9c83ec81389367b2c61d62c90e21ee

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.

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

lib/std/Io/Threaded.zig+1-1
...@@ -8689,7 +8689,6 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8689,7 +8689,6 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8689 return e;8689 return e;
8690 },8690 },
8691 };8691 };
8692 defer alertable_syscall.finish();
8693 waitForApcOrAlert();8692 waitForApcOrAlert();
8694 while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) {8693 while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) {
8695 alertable_syscall.checkCancel() catch |err| switch (err) {8694 alertable_syscall.checkCancel() catch |err| switch (err) {
...@@ -8700,6 +8699,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us...@@ -8700,6 +8699,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
8700 };8699 };
8701 waitForApcOrAlert();8700 waitForApcOrAlert();
8702 }8701 }
8702 alertable_syscall.finish();
8703 },8703 },
8704 } else |err| return err;8704 } else |err| return err;
8705 return ntReadFileResult(&io_status_block);8705 return ntReadFileResult(&io_status_block);