diff options
author | Björn Gustavsson <bjorn@erlang.org> | 2020-02-18 06:26:33 +0100 |
---|---|---|
committer | Björn Gustavsson <bjorn@erlang.org> | 2020-02-21 10:16:21 +0100 |
commit | 38df9be8e5fabf9de15524fe176696b7e3bbeac7 (patch) | |
tree | 04d854ba115edc3cd9c0adf424d2f3b9aec90353 /erts/emulator/test/trace_local_SUITE.erl | |
parent | 468b9a20b7f9d9585df750987b52e9e8f942f0ff (diff) | |
download | erlang-38df9be8e5fabf9de15524fe176696b7e3bbeac7.tar.gz |
Don't keep stacktraces forever
The `erlang:get_stacktrace/0` BIF retrieves the stacktrace from
the previous error in the process. The problem is that the very
existence of `erlang:get_stacktrace/0` means that the stacktrace
and potentially function arguments must be kept indefinitely.
Therefore, in OTP 21, the `erlang:get_stacktrace/0` BIF was deprecated
and the syntax of try/catch extended to allow matching out the
stacktrace directly.
This commit changes `erlang:get_stacktrace/0` for OTP 23 to always
return an empty list (`[]`) and eliminates the need to keep the
stacktrace forever.
`erlang:get_stacktrace/0` is scheduled for removal in OTP 24.
Diffstat (limited to 'erts/emulator/test/trace_local_SUITE.erl')
-rw-r--r-- | erts/emulator/test/trace_local_SUITE.erl | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/erts/emulator/test/trace_local_SUITE.erl b/erts/emulator/test/trace_local_SUITE.erl index ad802352b9..699964b4fb 100644 --- a/erts/emulator/test/trace_local_SUITE.erl +++ b/erts/emulator/test/trace_local_SUITE.erl @@ -1111,12 +1111,14 @@ x_exc_body(ExcOpts, {M,F}=Func, Args, Apply) -> end, {value,Value} catch - Thrown when Nocatch -> + throw:Thrown:Stk when Nocatch -> + put(get_stacktrace, Stk), CR = {error,{nocatch,Thrown}}, x_exc_exception(Rtt, M, F, Args, Arity, CR), expect({eft,{?MODULE,exc,2},CR}), CR; - Class:Reason -> + Class:Reason:Stk -> + put(get_stacktrace, Stk), CR = {Class,Reason}, x_exc_exception(Rtt, M, F, Args, Arity, CR), expect({eft,{?MODULE,exc,2},CR}), @@ -1157,7 +1159,8 @@ x_exc_exception(_Rtt, M, F, _, Arity, CR) -> expect({eft,{M,F,Arity},CR}). x_exc_stacktrace() -> - x_exc_stacktrace(erlang:get_stacktrace()). + x_exc_stacktrace(get(get_stacktrace)). + %% Truncate stacktrace to below exc/2 x_exc_stacktrace([{?MODULE,x_exc,4,_}|_]) -> []; x_exc_stacktrace([{?MODULE,x_exc_func,4,_}|_]) -> []; |