Skip to content
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

Minor crash when sending output to closed pipe #9055

Open
essen opened this issue Nov 13, 2024 · 2 comments
Open

Minor crash when sending output to closed pipe #9055

essen opened this issue Nov 13, 2024 · 2 comments
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@essen
Copy link
Contributor

essen commented Nov 13, 2024

Describe the bug
Seeing this when running Erlang.mk tests but very rarely:

RFailed to write log message to stdout, trying stderr
=ERROR REPORT==== 13-Nov-2024::12:24:26.444773 ===
Writer crashed (epipe)
untime terminating during boot ({terminated,[{io,put_chars,["done (passed successfully)\n"],[{file,"io.erl"},{line,198},{error_info,#{cause=>{io,terminated},module=>erl_stdlib_errors}}]},{dialyzer,cl_halt,2,[{file,"dialyzer.erl"},{line,691}]},{init,start_it,1,[]},{init,start_eFailed to write log message to stdout, trying stderr
m,1,[]},{init,do_boot,=ERROR REPORT==== 13-Nov-2024::12:24:26.481899 ===
Error in process <0.10.0> with exit value:
{terminated,[{io,put_chars,
                 ["done (passed successfully)\n"],
                 [{file,"io.erl"},
                  {line,198},
                  {error_info,#{cause => {io,terminated},
                                module => erl_stdlib_errors}}]},
             {dialyzer,cl_halt,2,[{file,"dialyzer.erl"},{line,691}]},
             {init,start_it,1,[]},
             {init,start_em,1,[]},
             {init,do_boot,3,[]}]}

3,[]}]})

Crash dump is being written to: erl_crash.dump...done

To Reproduce
Basically it happens because my tests do dialyzer --something | grep -q value and grep exits before Dialyzer has finished outputting everything.

Presumably this can reproduce eventually but I've only seen it twice:

git clone https://github.com/ninenines/erlang.mk
cd erlang.mk
make check c=dialyzer -j8 -k

Expected behavior
No error message, pipe was closed so Erlang should handle that gracefully.

Affected versions
OTP-27.1.2 at least.

Additional context
#3150

@essen essen added the bug Issue is reported as a bug label Nov 13, 2024
@garazdawi
Copy link
Contributor

This is caused by #6253. Before that change the dialyzer process just crashed without anything being logged. Now the crash is logged to stderr.

I think the solution here is to put a catch around the io:format in dialyzer. This error log message may be benign, but if we discard all log messages we will also throw away messages that would have been useful. We could also change io:format to not throw an error when stdout is closed, but just discard the output.

@garazdawi garazdawi self-assigned this Nov 14, 2024
@garazdawi garazdawi added the team:VM Assigned to OTP team VM label Nov 14, 2024
@essen
Copy link
Contributor Author

essen commented Nov 15, 2024

Adding a catch would only accidentally fix it. In my case grep matches on the previous io:format call and closes stdout, making the next io:format fail. But really any io:format after stdout closes could crash.

I think a proper fix would be to detect that stdout was closed normally (SIGPIPE?) and discard the output in that case (the recipient of the output doesn't want it anymore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

2 participants