Skip to content

Erlang/OTP 26 hangs when stdio is set utf-8 encoding without a terminal on Windows #7261

@josevalim

Description

@josevalim

Describe the bug

Take this module:

-module(foo).
-compile(export_all).

run() ->
  io:put_chars("START\n"),

  open_port(
    {spawn_executable, os:find_executable("erl")},
    [use_stdio, exit_status, binary, hide,
     {args, ["-eval", "io:setopts(standard_io, [{encoding, utf8}]), io:write(hello), erlang:halt()."]}]
  ),

  loop().

loop() ->
  receive
    {_, {data, Data}} ->
      io:put_chars(Data),
      loop();

    {_, {exit_status, _}} ->
      erlang:halt()
  end.

If you call erl -s foo run on Windows, it will hang because the open_port never completes. The io:write(hello) operation in the subprocess hangs once we set the encoding to io:setopts(standard_io, [{encoding, utf8}]). This only happens on Windows and only if we set the device to [{encoding, utf8}].

Affected versions
Erlang/OTP 26.

Metadata

Metadata

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions