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
86898689 return e;
86908690 },
86918691 };
8692 defer alertable_syscall.finish();
86938692 waitForApcOrAlert();
86948693 while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) {
86958694 alertable_syscall.checkCancel() catch |err| switch (err) {
......@@ -8700,6 +8699,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
87008699 };
87018700 waitForApcOrAlert();
87028701 }
8702 alertable_syscall.finish();
87038703 },
87048704 } else |err| return err;
87058705 return ntReadFileResult(&io_status_block);