aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-03-22 09:38:58 +0100
committerJohn Högberg <[email protected]>2019-03-22 09:38:58 +0100
commit83fb1f13596977beab8b426a23813d73d71f9c17 (patch)
treedbc163f3005164ad216b62c8206433ee24e12670
parent4c744d0c81273c4c53a0dd267baf46a71814196e (diff)
parent8473827449cfb8de65709278b4a23bb1577b6a0a (diff)
downloadotp-83fb1f13596977beab8b426a23813d73d71f9c17.tar.gz
otp-83fb1f13596977beab8b426a23813d73d71f9c17.tar.bz2
otp-83fb1f13596977beab8b426a23813d73d71f9c17.zip
Merge branch 'john/erts/fix-badarg-fixed_apply'
* john/erts/fix-badarg-fixed_apply: erts: Include argument list on badarg in fixed_apply
-rw-r--r--erts/emulator/beam/beam_emu.c14
-rw-r--r--erts/emulator/test/bif_SUITE.erl22
2 files changed, 29 insertions, 7 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index 04a2a83123..d68d021679 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -2310,12 +2310,16 @@ fixed_apply(Process* p, Eterm* reg, Uint arity,
function = reg[arity+1];
if (is_not_atom(function)) {
+ Eterm bad_args;
error:
- p->freason = BADARG;
- reg[0] = module;
- reg[1] = function;
- reg[2] = NIL;
- return 0;
+ bad_args = make_arglist(p, reg, arity);
+
+ p->freason = BADARG;
+ reg[0] = module;
+ reg[1] = function;
+ reg[2] = bad_args;
+
+ return 0;
}
if (is_not_atom(module)) goto error;
diff --git a/erts/emulator/test/bif_SUITE.erl b/erts/emulator/test/bif_SUITE.erl
index 3eedf2f6a6..43975d1800 100644
--- a/erts/emulator/test/bif_SUITE.erl
+++ b/erts/emulator/test/bif_SUITE.erl
@@ -38,7 +38,8 @@
is_process_alive/1,
process_info_blast/1,
os_env_case_sensitivity/1,
- test_length/1]).
+ test_length/1,
+ fixed_apply_badarg/1]).
suite() ->
[{ct_hooks,[ts_install_cth]},
@@ -54,7 +55,7 @@ all() ->
error_stacktrace, error_stacktrace_during_call_trace,
group_leader_prio, group_leader_prio_dirty,
is_process_alive, process_info_blast, os_env_case_sensitivity,
- test_length].
+ test_length,fixed_apply_badarg].
%% Uses erlang:display to test that erts_printf does not do deep recursion
display(Config) when is_list(Config) ->
@@ -1230,6 +1231,23 @@ test_length(I, N, Inc, Good, Bad) when I < N ->
lists:reverse(IncSeq, Bad));
test_length(_, _, _, _, _) -> ok.
+%% apply/3 with a fixed number of arguments didn't include all arguments on
+%% badarg exceptions.
+fixed_apply_badarg(Config) when is_list(Config) ->
+ Bad = id({}),
+
+ {'EXIT',{badarg, [{erlang,apply,[{},baz,[a,b]],[]} | _]}} =
+ (catch Bad:baz(a,b)),
+ {'EXIT',{badarg, [{erlang,apply,[baz,{},[c,d]],[]} | _]}} =
+ (catch baz:Bad(c,d)),
+
+ {'EXIT',{badarg, [{erlang,apply,[{},baz,[e,f]],[]} | _]}} =
+ (catch apply(Bad,baz,[e,f])),
+ {'EXIT',{badarg, [{erlang,apply,[baz,{},[g,h]],[]} | _]}} =
+ (catch apply(baz,Bad,[g,h])),
+
+ ok.
+
%% helpers
id(I) -> I.