aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_except.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-01-28 11:30:39 +0100
committerBjörn Gustavsson <[email protected]>2019-01-28 12:50:49 +0100
commitda72cd451dc29757c7297cba4ee3939f6d6cb1c1 (patch)
treecf1c710ccd230f979df535dcd9b148a41cafb8bd /lib/compiler/src/beam_except.erl
parent1ea703443fa0bbc3aade0bb61fc96b2f0cf6b84c (diff)
downloadotp-da72cd451dc29757c7297cba4ee3939f6d6cb1c1.tar.gz
otp-da72cd451dc29757c7297cba4ee3939f6d6cb1c1.tar.bz2
otp-da72cd451dc29757c7297cba4ee3939f6d6cb1c1.zip
beam_except: Eliminate unsafe function_clause translation
The translation from `error(function_clause, Args)` to a jump to the `func_info` label is not safe if there is a stack frame.
Diffstat (limited to 'lib/compiler/src/beam_except.erl')
-rw-r--r--lib/compiler/src/beam_except.erl12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_except.erl b/lib/compiler/src/beam_except.erl
index 49bfb5606f..26b193a35b 100644
--- a/lib/compiler/src/beam_except.erl
+++ b/lib/compiler/src/beam_except.erl
@@ -79,13 +79,15 @@ translate_1(Ar, I, Is, #st{arity=Arity}=St, [{line,_}=Line|Acc1]=Acc0) ->
no ->
translate(Is, St, [I|Acc0]);
{yes,function_clause,Acc2} ->
- case {Line,St} of
- {{line,Loc},#st{lbl=Fi,loc=Loc}} ->
+ case {Is,Line,St} of
+ {[return|_],{line,Loc},#st{lbl=Fi,loc=Loc}} ->
Instr = {jump,{f,Fi}},
translate(Is, St, [Instr|Acc2]);
- {_,_} ->
- %% This must be "error(function_clause, Args)" in
- %% the Erlang source code or a fun. Don't translate.
+ {_,_,_} ->
+ %% Not a call_only instruction, or not the same
+ %% location information as in in the line instruction
+ %% before the func_info instruction. Not safe
+ %% to translate to a jump.
translate(Is, St, [I|Acc0])
end;
{yes,Instr,Acc2} ->