You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I've started learning Zig on windows, I'm using VSCode.
VSCode has embedded terminals such as PowerShell, cmd, git bash (mingw), etc.
Not sure how it was made, that might be named pipes or anything else.
It is very common situation, when you write a code in VsCode and then compile it in integrated terminal
The problem is: when Zig program has print's it can throw exception when printed in that embedded terminal.
Minimal code to reproduce
So when we build via zig build run in terminal (it can have 10 successful runs, but the 11th one gives exception)
(If it panics with 2 digit printing like 11 or 20 we will get panic: start index 4 is larger than end index 2)
writer.zig:
pub fn writeAll(self: Self, bytes: []const u8) Error!void {
var index: usize = 0;
while (index != bytes.len) {
index += try self.write(bytes[index..]);
}
}
Here we have an index, that is incremented by number of written bytes and we get that error index > bytes.len. I understand, self.write may try to write 5 bytes of 10 (for ex.) so will return 5, which will lead to next write iteration.
I'm not sure about index != bytes.len, yes of course, in any usual situation index must not be greater than bytes.len, but I found that parcticular one.
On windows self.write goes to std/os/windows.zig into function WriteFile which is wrapper for API.
As far as I got it, kernel32.WriteFile returns not a 0, so we don't have any error.
But here the bytes_written is doubled. It only happens in integrated VSCode terminal. It repeats with zig build run and also builded exe .\zig-out\bin\test.exe, it repeats when outed in stdout and stderr and as I've seen, with out in stderr that happens more often,
Expected Behavior
Can't reproduce it with standalone cmd/Powershell, but have seen it with only 2 print's in code, Less print's = rare exceptions.
The text was updated successfully, but these errors were encountered:
ndbn
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Aug 27, 2023
Seems yes. I really use Win10 before that 2018' Spring Creators Update.
I wouldn't have guessed that! Glad I decided to mention it in case it was related. I'm sure there's others out there in the same boat as you. Hopefully this issue report can help them in the future.
I wouldn't have guessed that! Glad I decided to mention it in case it was related. I'm sure there's others out there in the same boat as you. Hopefully this issue report can help them in the future.
Yes, thanks for that. It still rare situation, I use node.js and rust earlier in VSCode and there was no problem with output.
Zig Version
0.12.0-dev.152+411462e1c
Steps to Reproduce and Observed Behavior
Hello. I've started learning Zig on windows, I'm using VSCode.
VSCode has embedded terminals such as PowerShell, cmd, git bash (mingw), etc.
Not sure how it was made, that might be named pipes or anything else.
It is very common situation, when you write a code in VsCode and then compile it in integrated terminal
The problem is: when Zig program has print's it can throw exception when printed in that embedded terminal.
Minimal code to reproduce
So when we build via
zig build run
in terminal (it can have 10 successful runs, but the 11th one gives exception)(If it panics with 2 digit printing like 11 or 20 we will get
panic: start index 4 is larger than end index 2
)writer.zig:
Here we have an index, that is incremented by number of written bytes and we get that error
index > bytes.len
. I understand,self.write
may try to write 5 bytes of 10 (for ex.) so will return 5, which will lead to next write iteration.I'm not sure about
index != bytes.len
, yes of course, in any usual situation index must not be greater than bytes.len, but I found that parcticular one.On windows self.write goes to
std/os/windows.zig
into functionWriteFile
which is wrapper for API.As far as I got it, kernel32.WriteFile returns not a 0, so we don't have any
error
.But here the bytes_written is doubled. It only happens in integrated VSCode terminal. It repeats with
zig build run
and also builded exe.\zig-out\bin\test.exe
, it repeats when outed in stdout and stderr and as I've seen, with out in stderr that happens more often,Expected Behavior
Can't reproduce it with standalone cmd/Powershell, but have seen it with only 2 print's in code, Less print's = rare exceptions.
The text was updated successfully, but these errors were encountered: