aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2019-07-10 18:05:11 +0200
committerErlang/OTP <[email protected]>2019-07-10 18:05:11 +0200
commit0a1020a860576502ca2c442b2ffd6faba3207217 (patch)
treee26660518783d87e46262d38d51207e73e7f582e
parentfa5e2cae48323a391ff65512a972d6c9f4ba4119 (diff)
parent9ca0e82455297040069b8274649e7ddd28a5d65b (diff)
downloadotp-0a1020a860576502ca2c442b2ffd6faba3207217.tar.gz
otp-0a1020a860576502ca2c442b2ffd6faba3207217.tar.bz2
otp-0a1020a860576502ca2c442b2ffd6faba3207217.zip
Merge branch 'john/compiler/fix-bad-try_catch-recv-fix/OTP-15953/ERL-999' into maint-22
* john/compiler/fix-bad-try_catch-recv-fix/OTP-15953/ERL-999: compiler: Fix compiler crash introduced by OTP-15952
-rw-r--r--lib/compiler/src/beam_ssa_pre_codegen.erl6
-rw-r--r--lib/compiler/test/beam_ssa_SUITE.erl15
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl
index a2e687930b..7ef604d444 100644
--- a/lib/compiler/src/beam_ssa_pre_codegen.erl
+++ b/lib/compiler/src/beam_ssa_pre_codegen.erl
@@ -1472,10 +1472,14 @@ find_loop_exit([L1,L2|_Ls], Blocks) ->
find_loop_exit_1(Path1, cerl_sets:from_list(Path2));
find_loop_exit(_, _) -> none.
+find_loop_exit_1([?BADARG_BLOCK | T], OtherPath) ->
+ %% ?BADARG_BLOCK is a marker and not an actual block, so we can't consider
+ %% it to be a common block even if both paths cross it.
+ find_loop_exit_1(T, OtherPath);
find_loop_exit_1([H|T], OtherPath) ->
case cerl_sets:is_element(H, OtherPath) of
true -> H;
- false -> find_loop_exit_1(T, OtherPath)
+ false -> find_loop_exit_1(T, OtherPath)
end;
find_loop_exit_1([], _) -> none.
diff --git a/lib/compiler/test/beam_ssa_SUITE.erl b/lib/compiler/test/beam_ssa_SUITE.erl
index 256bb95559..dd1b7ddcd3 100644
--- a/lib/compiler/test/beam_ssa_SUITE.erl
+++ b/lib/compiler/test/beam_ssa_SUITE.erl
@@ -196,6 +196,9 @@ recv(_Config) ->
self() ! 2,
b = tricky_recv_5(),
+ %% tricky_recv_6/0 is a compile-time error.
+ tricky_recv_6(),
+
ok.
sync_wait_mon({Pid, Ref}, Timeout) ->
@@ -321,6 +324,18 @@ tricky_recv_5() ->
_:_ -> c
end.
+%% When fixing tricky_recv_5, we introduced a compiler crash when the common
+%% exit block was ?BADARG_BLOCK and floats were in the picture.
+tricky_recv_6() ->
+ RefA = make_ref(),
+ RefB = make_ref(),
+ receive
+ {RefA, Number} -> Number + 1.0;
+ {RefB, Number} -> Number + 2.0
+ after 0 ->
+ ok
+ end.
+
maps(_Config) ->
{'EXIT',{{badmatch,#{}},_}} = (catch maps_1(any)),
ok.