From 7ff352ef8a5393a017ce493ba1a1fc3be54be245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 10 May 2017 14:20:13 +0200 Subject: Do not discard stacktraces on gen_server exits Prior to this patch, the stacktrace of an error or exit in a callback would always be discarded in crash reports. For example, an exit(crashed) in handle_call/3 would emit: =CRASH REPORT==== 10-May-2017::14:15:50 === crasher: initial call: gen_server_SUITE:init/1 pid: <0.201.0> registered_name: [] exception exit: crashed in function gen_server:terminate/8 (src/gen_server.erl, line 828) Note that the stacktrace is pointing to the gen_server internal terminate implementation that calls exit/1. This patch uses erlang:raise/3 so the stacktrace is not lost, allowing proc_lib to show the class, reason and stacktrace coming from the user implementation (in this case gen_server_SUITE): =CRASH REPORT==== 10-May-2017::14:16:44 === crasher: initial call: gen_server_SUITE:init/1 pid: <0.197.0> registered_name: [] exception exit: crashed in function gen_server_SUITE:handle_call/3 (gen_server_SUITE.erl, line 1529) This change is completely backwards compatible as using erlang:raise/3 will still emit the same exit reason to any linked process and monitor as before. --- lib/stdlib/test/gen_server_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/stdlib/test/gen_server_SUITE.erl') diff --git a/lib/stdlib/test/gen_server_SUITE.erl b/lib/stdlib/test/gen_server_SUITE.erl index 7e3c71715e..2e9dc4d4fb 100644 --- a/lib/stdlib/test/gen_server_SUITE.erl +++ b/lib/stdlib/test/gen_server_SUITE.erl @@ -404,7 +404,7 @@ crash(Config) when is_list(Config) -> end, receive {error_report,_,{Pid4,crash_report,[List4|_]}} -> - {exit,crashed,_} = proplists:get_value(error_info, List4), + {exit,crashed,[{?MODULE, handle_call, 3, _}|_]} = proplists:get_value(error_info, List4), Pid4 = proplists:get_value(pid, List4); Other4 -> io:format("Unexpected: ~p", [Other4]), -- cgit v1.2.3