diff options
Diffstat (limited to 'erts/emulator/test/trace_SUITE.erl')
-rw-r--r-- | erts/emulator/test/trace_SUITE.erl | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/erts/emulator/test/trace_SUITE.erl b/erts/emulator/test/trace_SUITE.erl index c2d5cd7023..951502cb61 100644 --- a/erts/emulator/test/trace_SUITE.erl +++ b/erts/emulator/test/trace_SUITE.erl @@ -39,7 +39,7 @@ system_monitor_large_heap_1/1, system_monitor_large_heap_2/1, system_monitor_long_schedule/1, bad_flag/1, trace_delivered/1, trap_exit_self_receive/1, - trace_info_badarg/1, erl_704/1]). + trace_info_badarg/1, erl_704/1, ms_excessive_nesting/1]). -include_lib("common_test/include/ct.hrl"). @@ -63,7 +63,8 @@ all() -> system_monitor_long_gc_2, system_monitor_large_heap_1, system_monitor_long_schedule, system_monitor_large_heap_2, bad_flag, trace_delivered, - trap_exit_self_receive, trace_info_badarg, erl_704]. + trap_exit_self_receive, trace_info_badarg, erl_704, + ms_excessive_nesting]. init_per_testcase(_Case, Config) -> [{receiver,spawn(fun receiver/0)}|Config]. @@ -664,7 +665,7 @@ dist_procs_trace(Config) when is_list(Config) -> Proc1 ! {trap_exit_please, true}, Proc3 = receive {spawned, Proc1, P3} -> P3 end, io:format("Proc3 = ~p ~n", [Proc3]), - {trace, Proc1, getting_linked, Proc3} = receive_first_trace(), + {trace, Proc1, link, Proc3} = receive_first_trace(), Reason3 = make_ref(), Proc1 ! {send_please, Proc3, {exit_please, Reason3}}, receive {Proc1, {'EXIT', Proc3, Reason3}} -> ok end, @@ -958,15 +959,14 @@ do_system_monitor_long_schedule() -> {Self,L} when is_list(L) -> ok after 1000 -> - ct:fail(no_trace_of_pid) + ct:fail(no_trace_of_pid) end, "ok" = erlang:port_control(Port,1,[]), - "ok" = erlang:port_control(Port,2,[]), receive {Port,LL} when is_list(LL) -> ok after 1000 -> - ct:fail(no_trace_of_port) + ct:fail(no_trace_of_port) end, port_close(Port), erlang:system_monitor(undefined), @@ -1684,6 +1684,18 @@ bad_flag(Config) when is_list(Config) -> {'EXIT', {badarg, _}} = (catch erlang:trace(new, true, [not_a_valid_flag])), + + %% Leaks of {tracer,_} in OTP 23.2 + Pid = spawn(fun() -> receive die -> ok end end), + 1 = erlang:trace(Pid, true, [{tracer, self()}, + {tracer, self()}]), + Pid ! die, + {'EXIT', {badarg, _}} = + (catch erlang:trace(new, true, [{tracer, self()} + | improper])), + {'EXIT', {badarg, _}} = + (catch erlang:trace(new, true, [{tracer, self()}, + not_a_valid_flag])), ok. %% Test erlang:trace_delivered/1 @@ -1754,6 +1766,33 @@ erl_704_test(N) -> (catch erlang:resume_process(P)), erl_704_test(N-1). +ms_excessive_nesting(Config) when is_list(Config) -> + MkMSCond = fun (_Fun, N) when N < 0 -> true; + (Fun, N) -> {'or', {'=:=', N, '$1'}, Fun(Fun, N-1)} + end, + %% Ensure it compiles with substantial but reasonable + %% (hmm...) nesting + MS = [{['$1'], [MkMSCond(MkMSCond, 100)], []}], + io:format("~p~n", [erlang:match_spec_test([1], MS, trace)]), + _ = erlang:trace_pattern({?MODULE, '_', '_'}, MS, []), + %% Now test a match spec using excessive nesting. This + %% used to seg-fault the emulator due to recursion + %% beyond the end of the C-stack. + %% + %% We expect to get a system_limit error, but don't + %% fail if it compiles (someone must have rewritten + %% compilation of match specs to use an explicit + %% stack instead of using recursion). + ENMS = [{['$1'], [MkMSCond(MkMSCond, 1000000)], []}], + io:format("~p~n", [erlang:match_spec_test([1], ENMS, trace)]), + try + _ = erlang:trace_pattern({?MODULE, '_', '_'}, ENMS, []), + {comment, "compiled"} + catch + error:system_limit -> + {comment, "got system_limit"} + end. + drop_trace_until_down(Proc, Mon) -> drop_trace_until_down(Proc, Mon, false, 0, 0). |