From 890bc8dddd62b5e14fd9bd38ea3317e47cc0b716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 17 May 2017 12:38:09 +0200 Subject: escript: Pick up stacktrace a soon as possible It happens to work today, but it is potentially unsafe to call io:format/2 before calling erlang:get_stacktrace/0. Make the code safe by calling erlang:get_stacktrace/0 directly after catching the exception. --- lib/stdlib/src/escript.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/stdlib/src/escript.erl') diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl index 6e8f780f7c..f2629a47c2 100644 --- a/lib/stdlib/src/escript.erl +++ b/lib/stdlib/src/escript.erl @@ -284,8 +284,9 @@ start(EscriptOptions) -> io:format("escript: ~s\n", [Str]), my_halt(127); _:Reason -> + Stk = erlang:get_stacktrace(), io:format("escript: Internal error: ~p\n", [Reason]), - io:format("~p\n", [erlang:get_stacktrace()]), + io:format("~p\n", [Stk]), my_halt(127) end. -- cgit v1.2.3