Skip to content

Commit

Permalink
Merge branch 'lukas/erts/tracing/bif_return_to_trace_fix/OTP-13734' i…
Browse files Browse the repository at this point in the history
…nto maint

* lukas/erts/tracing/bif_return_to_trace_fix/OTP-13734:
  erts: After a call to a tracer nif, reset htop
  erts: Check if return_to trace is enabled for bif
  • Loading branch information
garazdawi committed Jul 11, 2016
2 parents 26a8234 + 3b18641 commit a5256e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion erts/emulator/beam/beam_bp.c
Expand Up @@ -858,7 +858,8 @@ erts_bif_trace(int bif_index, Process* p, Eterm* args, BeamInstr* I)
if (flags & MATCH_SET_RX_TRACE) {
erts_trace_return(p, ep->code, result, &ERTS_TRACER(p));
}
if (flags & MATCH_SET_RETURN_TO_TRACE) {
if (flags & MATCH_SET_RETURN_TO_TRACE &&
IS_TRACED_FL(p, F_TRACE_RETURN_TO)) {
/* can only happen if(local)*/
if (applying) {
/* Apply of BIF, cp is in calling function */
Expand Down
2 changes: 2 additions & 0 deletions erts/emulator/beam/erl_nif.c
Expand Up @@ -3502,6 +3502,7 @@ Eterm erts_nif_call_function(Process *p, Process *tracee,
struct enif_environment_t env;
ErlHeapFragment *orig_hf = MBUF(p);
ErlOffHeap orig_oh = MSO(p);
Eterm *orig_htop = HEAP_TOP(p);
ASSERT(is_internal_pid(p->common.id));
MBUF(p) = NULL;
clear_offheap(&MSO(p));
Expand All @@ -3523,6 +3524,7 @@ Eterm erts_nif_call_function(Process *p, Process *tracee,
/* restore original heap fragment list */
MBUF(p) = orig_hf;
MSO(p) = orig_oh;
HEAP_TOP(p) = orig_htop;
} else {
/* Nif call was done without a process context,
so we create a phony one. */
Expand Down
8 changes: 8 additions & 0 deletions erts/emulator/test/trace_local_SUITE.erl
Expand Up @@ -439,6 +439,14 @@ return_test() ->
?RT(?MODULE,slave,2),
shutdown(),
?NM,

%% Test a regression where turning off return_to tracing
%% on yourself would cause a segfault.
Pid = setup([call,return_to]),
erlang:trace_pattern({'_','_','_'},[],[local]),
apply_slave(erlang,trace,[Pid, false, [all]]),
shutdown(),

ok.

on_and_off_test() ->
Expand Down

0 comments on commit a5256e5

Please sign in to comment.