Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/libAtomVM/opcodesswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5384,13 +5384,13 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
READ_ANY_XREG(function, arity + 1);
TRACE("apply_last/1, module=%lu, function=%lu arity=%i deallocate=%i\n", module, function, arity, n_words);

ctx->cp = ctx->e[n_words];
ctx->e += (n_words + 1);

if (UNLIKELY(!term_is_atom(module) || !term_is_atom(function))) {
RAISE_ERROR(BADARG_ATOM);
}

ctx->cp = ctx->e[n_words];
ctx->e += (n_words + 1);

AtomString module_name = globalcontext_atomstring_from_term(glb, module);
AtomString function_name = globalcontext_atomstring_from_term(glb, function);

Expand Down
16 changes: 15 additions & 1 deletion tests/erlang_tests/fail_apply_last.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,25 @@ try_apply_last(M, F) ->
try
?MODULE:do_apply0(M, F)
catch
_Class:_Reason -> 1
_Class:_Reason:Stack ->
test_stacktrace(Stack, false, false, 1)
end.

pad_some_calls() ->
X = 1,
Y = 2,
Z = X + Y,
Z.

% if try_apply_last/2 is in stacktrace, we also want do_apply0/2
test_stacktrace([], _, _, R) ->
R;
test_stacktrace([{?MODULE, try_apply_last, 2, _} | T], false, DoApply0, R) ->
test_stacktrace(T, true, DoApply0, R - 1);
test_stacktrace([{?MODULE, do_apply0, 2, _} | T], TryApplyLast, false, R) ->
test_stacktrace(T, TryApplyLast, true, R + 1);
test_stacktrace([_ | T], TryApplyLast, DoApply0, R) ->
test_stacktrace(T, TryApplyLast, DoApply0, R);
test_stacktrace(undefined, _, _, R) ->
% AVM_CREATE_STACKTRACES=off
R.
Loading