-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Erlang/OTP 26 write to stdout hangs in latin1 encoding on Windows #7459
Comments
It is indeed #7261 that failed to solve the entire problem. Windows seems to treat input differently depending on whether it is a console, a file, or a pipe. The code in #7261 works when the input is a console or a file, but it does not work for a pipe... I'm unsure if it is at all possible to achieve non-blocking I/O when STDIN is a pipe... I'll continue digging and see what I get figure out, worse case we may have to live with a blocking API and just make sure that when it happens the rest of the system does not dead-lock. |
I think I've fixed the issue, but as I did I stumbled across other problems in this area that I need to look closer at before releasing a patch. One interesting thing I found was that apparently |
In some situations the call to read_nif can block until data is available (for example if input is a pipe on Windows) so the code to set the encoding must be asynchronous otherwise we can end up with a deadlock. closes erlang#7459
In some situations the call to read_nif can block until data is available (for example if input is a pipe on Windows) so the code to set the encoding must be asynchronous otherwise we can end up with a deadlock. closes erlang#7459
The fix is implemented in #7473 together with some changes in how bytewise (latin1) encoding is handled in general. I've also included some documentation about how things are supposed to work and be used. Hopefully, it will make it easier for anyone else trying to do the same thing. |
Describe the bug
After changing
standard_io
encoding tolatin1
all writes to the output device hang.To Reproduce
Run from windows command prompt
Result on windows
Expected behavior
Should print
it works correctly on OTP 25 both windows and *nix, and on OTP 26.0.2 on *nix
Affected versions
OTP 26.0.2
Additional context
This bug was tricky to track as it hangs only with a spawned process. If the same code is run directly from cmd shell it works correctly
prints
This bug breaks ElixirLS on windows elixir-lsp/elixir-ls#927
Possibly this is a regression of #7261 once fixed in 2bbeed3. The original script from that bug as well as a modified one hangs as well
Related to #7230, #7384
The text was updated successfully, but these errors were encountered: