aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-02-19 13:34:22 +0100
committerBjörn Gustavsson <[email protected]>2015-02-20 08:02:09 +0100
commit1899aa487d898078e6e7b1c6b7ea3aa5ea31c7e5 (patch)
treebc2a1a4de544a527ee38805b5ee5811cdb7f8ed5 /lib/compiler/test
parent9d8327c62a981bcc436e5f9fc5466f5539dce3dc (diff)
downloadotp-1899aa487d898078e6e7b1c6b7ea3aa5ea31c7e5.tar.gz
otp-1899aa487d898078e6e7b1c6b7ea3aa5ea31c7e5.tar.bz2
otp-1899aa487d898078e6e7b1c6b7ea3aa5ea31c7e5.zip
beam_jump: Don't jump into the middle of a 'try'
The code sharing optimization could produce a jump into the middle of a 'try' block. beam_validator would reject the code. Reported-by: Ulf Norell
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/trycatch_SUITE.erl17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/compiler/test/trycatch_SUITE.erl b/lib/compiler/test/trycatch_SUITE.erl
index 8ab618bb01..80d93fbfa4 100644
--- a/lib/compiler/test/trycatch_SUITE.erl
+++ b/lib/compiler/test/trycatch_SUITE.erl
@@ -24,7 +24,8 @@
catch_oops/1,after_oops/1,eclectic/1,rethrow/1,
nested_of/1,nested_catch/1,nested_after/1,
nested_horrid/1,last_call_optimization/1,bool/1,
- plain_catch_coverage/1,andalso_orelse/1,get_in_try/1]).
+ plain_catch_coverage/1,andalso_orelse/1,get_in_try/1,
+ hockey/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -39,7 +40,8 @@ groups() ->
[basic,lean_throw,try_of,try_after,catch_oops,
after_oops,eclectic,rethrow,nested_of,nested_catch,
nested_after,nested_horrid,last_call_optimization,
- bool,plain_catch_coverage,andalso_orelse,get_in_try]}].
+ bool,plain_catch_coverage,andalso_orelse,get_in_try,
+ hockey]}].
init_per_suite(Config) ->
@@ -943,3 +945,14 @@ get_valid_line([_|T]=Path, Annotations) ->
_:not_found ->
get_valid_line(T, Annotations)
end.
+
+hockey(_) ->
+ {'EXIT',{{badmatch,_},[_|_]}} = (catch hockey()),
+ ok.
+
+hockey() ->
+ %% beam_jump used to generate a call into the try block.
+ %% beam_validator disapproved.
+ receive _ -> (b = fun() -> ok end)
+ + hockey, +x after 0 -> ok end, try (a = fun() -> ok end) + hockey, +
+ y catch _ -> ok end.