aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test/receive_SUITE.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-08-14 13:31:27 +0200
committerGitHub <[email protected]>2019-08-14 13:31:27 +0200
commit29852da8ef813ece12137e6477abed838c4d56c6 (patch)
treecf858fe56a17ced9d27424f9aa963aa0fbe92096 /lib/compiler/test/receive_SUITE.erl
parent4e0300d788a1cecace36aca67f81e50b85a6bc08 (diff)
parentc5e36feada9d0362108890f42c40dd2398b1b531 (diff)
downloadotp-29852da8ef813ece12137e6477abed838c4d56c6.tar.gz
otp-29852da8ef813ece12137e6477abed838c4d56c6.tar.bz2
otp-29852da8ef813ece12137e6477abed838c4d56c6.zip
Merge pull request #2347 from bjorng/bjorn/compiler/fix-receive-bug/ERL-1022/OTP-15982
Fix compiler crash when compiling some receive statements
Diffstat (limited to 'lib/compiler/test/receive_SUITE.erl')
-rw-r--r--lib/compiler/test/receive_SUITE.erl35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/compiler/test/receive_SUITE.erl b/lib/compiler/test/receive_SUITE.erl
index 752491f0f8..8cd864c59e 100644
--- a/lib/compiler/test/receive_SUITE.erl
+++ b/lib/compiler/test/receive_SUITE.erl
@@ -431,6 +431,20 @@ elusive_common_exit(_Config) ->
self() ! {1, a},
self() ! {2, b},
{[z], [{2,b},{1,a}]} = elusive_loop([x,y,z], 2, []),
+
+ CodeServer = whereis(code_server),
+ Self = self(),
+ Self ! {Self, abc},
+ Self ! {CodeServer, []},
+ Self ! {Self, other},
+ try elusive2([]) of
+ Unexpected ->
+ ct:fail("Expected an exception; got ~p\n", [Unexpected])
+ catch
+ throw:[other, CodeServer, Self] ->
+ ok
+ end,
+
ok.
elusive_loop(List, 0, Results) ->
@@ -449,4 +463,25 @@ elusive_loop(List, ToReceive, Results) ->
%% that it would not insert all necessary copy instructions.
elusive_loop(RemList, ToReceive-1, [Result | Results]).
+
+elusive2(Acc) ->
+ receive
+ {Pid, abc} ->
+ ok;
+ {Pid, []} ->
+ ok;
+ {Pid, Res} ->
+ %% beam_ssa_pre_codegen:find_loop_exit/2 attempts to find
+ %% the first block of the common code after the receive
+ %% statement. It used to only look at the two last clauses
+ %% of the receive. In this function, the last two clauses
+ %% don't have any common block, so it would be assumed
+ %% that there was no common block for any of the
+ %% clauses. That would mean that copy instructions would
+ %% not be inserted as needed.
+ throw([Res | Acc])
+ end,
+ %% Common code.
+ elusive2([Pid | Acc]).
+
id(I) -> I.