[erlang-questions] Erlang VM crashed due to io output?

Roger Larsson roger.larsson@REDACTED
Thu Jul 19 12:22:46 CEST 2007


On Thursday 19 July 2007 11:16, Ludovic Coquelle wrote:
> - - -
> That's the behaviour I expected.
> But if I try to pipe the result, erlang crash:
> bash> erl -noshell -eval "lists:foreach(fun(N) -> io:format(\"~w~n\", [N])
> end, lists:seq(1,5)), erlang:halt()." | head -n 3
> 1
> 2
> 3
> Crash dump was written to: erl_crash.dump
> init terminating in do_boot ()
>
> What's happening?

To see this you need to have core file size != 0
bash> ulimit -c 1000

My guess:
When head has received three values it exits. (try with "tail -n 3", it works)
This cause the pipe (stdout) to terminate.
Erlang misinterprets this as an abnormal situation and dumps core.

> Is it a normal behaviour?

Maybe. But I rewrote it and tried to run it as a script

---------------
#!/usr/bin/env escript
%% -*- erlang -*-

main([]) ->
 lists:foreach(fun(N) -> io:format("~w~n", [N])
 end, lists:seq(1,5)).
------------------
And it still dumps core - not OK!

/RogerL




More information about the erlang-questions mailing list