From 30e32e51a66ac3dbd898788507ce0d44348db93d Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Mon, 20 Aug 2018 16:37:00 +0200 Subject: [PATCH 1/6] Small refactoring --- src/concuerror_callback.erl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/concuerror_callback.erl b/src/concuerror_callback.erl index c4d563fa3..66a99a97b 100644 --- a/src/concuerror_callback.erl +++ b/src/concuerror_callback.erl @@ -1852,8 +1852,8 @@ exiting(Reason, Stacktrace, InfoIn) -> FunFold = fun(Fun, Acc) -> Fun(Acc) end, FunList = [fun ets_ownership_exiting_events/1, - link_monitor_handlers(links, fun handle_link/4, Links), - link_monitor_handlers(monitors, fun handle_monitor/4, Monitors)], + link_monitor_handlers(fun handle_link/4, Links), + link_monitor_handlers(fun handle_monitor/4, Monitors)], NewInfo = ExitInfo#concuerror_info{exit_reason = Reason}, FinalInfo = lists:foldl(FunFold, NewInfo, FunList), ?debug_flag(?loop, exited), @@ -1911,17 +1911,14 @@ handle_monitor({Ref, P, As}, S, Reason, InfoIn) -> instrumented(call, MFArgs, exit, InfoIn), NewInfo. -link_monitor_handlers(Type, Handler, LinksOrMonitors) -> +link_monitor_handlers(Handler, LinksOrMonitors) -> fun(Info) -> #concuerror_info{exit_reason = Reason} = Info, - HandleActive = + Fold = fun({LinkOrMonitor, S}, InfoIn) -> - case S =:= active orelse Type =:= monitors of - true -> Handler(LinkOrMonitor, S, Reason, InfoIn); - false -> InfoIn - end + Handler(LinkOrMonitor, S, Reason, InfoIn) end, - lists:foldl(HandleActive, Info, LinksOrMonitors) + lists:foldl(Fold, Info, LinksOrMonitors) end. %%------------------------------------------------------------------------------ From 081478052486bf3313e89425f1bc1fa75c5f9fa7 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Tue, 21 Aug 2018 09:42:49 +0200 Subject: [PATCH 2/6] Do not export duplicate covers --- src/concuerror.erl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/concuerror.erl b/src/concuerror.erl index 2213b4b3b..aa762f8ef 100644 --- a/src/concuerror.erl +++ b/src/concuerror.erl @@ -176,8 +176,9 @@ start(Options, LogMsgs) -> maybe_cover_compile() -> Cover = os:getenv("CONCUERROR_COVER"), - case Cover =/= false of + case get(concuerror_cover) =:= undefined andalso Cover =/= false of true -> + put(concuerror_cover, Cover), case cover:is_compiled(?MODULE) of false -> {ok, Modules} = application:get_key(concuerror, modules), @@ -191,8 +192,8 @@ maybe_cover_compile() -> %%------------------------------------------------------------------------------ maybe_cover_export(Args) -> - Cover = os:getenv("CONCUERROR_COVER"), - case Cover =/= false of + Cover = erase(concuerror_cover), + case Cover =/= undefined of true -> Hash = binary:decode_unsigned(erlang:md5(term_to_binary(Args))), Out = filename:join([Cover, io_lib:format("~.16b", [Hash])]), From 3edf79c6467229440179fc5a2c1f59049965a571 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Tue, 21 Aug 2018 09:56:11 +0200 Subject: [PATCH 3/6] Eliminate unreachable code --- src/concuerror_callback.erl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/concuerror_callback.erl b/src/concuerror_callback.erl index 66a99a97b..27682cecf 100644 --- a/src/concuerror_callback.erl +++ b/src/concuerror_callback.erl @@ -311,15 +311,11 @@ built_in(erlang, Display, 1, [Term], _Location, Info) end, concuerror_logger:print(Info#concuerror_info.logger, standard_io, Chars), {{didit, true}, Info}; -%% Process dictionary has been restored here. No need to report such ops. +%% Inner process dictionary has been restored here. No need to report such ops. +%% Also can't fail, as only true builtins reach this code. built_in(erlang, Name, _Arity, Args, _Location, Info) when Name =:= get; Name =:= get_keys; Name =:= put; Name =:= erase -> - try - {{didit, erlang:apply(erlang, Name, Args)}, Info} - catch - error:Reason -> {{error, Reason}, Info} - end; -%% XXX: Temporary + {{didit, erlang:apply(erlang, Name, Args)}, Info}; built_in(erlang, hibernate, 3, Args, _Location, Info) -> [Module, Name, HibArgs] = Args, self() ! {start, Module, Name, HibArgs}, From 8ba64e96166035f68871f1f5860daf596fb00990 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Tue, 21 Aug 2018 10:23:48 +0200 Subject: [PATCH 4/6] Cover more lines in instrumenter --- src/concuerror_instrumenter.erl | 3 +- .../safeops_coverage-test-inf-optimal.txt | 48 +++++++++++++++++++ .../basic_tests/src/safeops_coverage.erl | 21 ++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/suites/basic_tests/results/safeops_coverage-test-inf-optimal.txt create mode 100644 tests/suites/basic_tests/src/safeops_coverage.erl diff --git a/src/concuerror_instrumenter.erl b/src/concuerror_instrumenter.erl index db1b81417..77a6b93cd 100644 --- a/src/concuerror_instrumenter.erl +++ b/src/concuerror_instrumenter.erl @@ -179,6 +179,8 @@ is_unsafe({erlang, F, A}) -> StringF = atom_to_list(F), not erl_safe(StringF) end; +is_unsafe({erts_internal, garbage_collect, _}) -> + false; is_unsafe({Safe, _, _}) when Safe =:= binary @@ -230,7 +232,6 @@ erl_safe("fun_info" ++ _) -> true; erl_safe("function_exported" ) -> true; erl_safe("garbage_collect" ) -> true; erl_safe("get_module_info" ) -> true; -erl_safe("hash" ) -> true; erl_safe("hibernate" ) -> false; %% Must be instrumented. erl_safe("insert_element" ) -> true; erl_safe("iolist_size" ) -> true; diff --git a/tests/suites/basic_tests/results/safeops_coverage-test-inf-optimal.txt b/tests/suites/basic_tests/results/safeops_coverage-test-inf-optimal.txt new file mode 100644 index 000000000..6c7d9681c --- /dev/null +++ b/tests/suites/basic_tests/results/safeops_coverage-test-inf-optimal.txt @@ -0,0 +1,48 @@ +Concuerror AFS2018+build.2175.reff4adefa started at 21 Aug 2018 10:17:50 + Options: + [{after_timeout,infinity}, + {assertions_only,false}, + {assume_racing,false}, + {depth_bound,500}, + {disable_sleep_sets,false}, + {dpor,optimal}, + {entry_point,{safeops_coverage,test,[]}}, + {exclude_module,[]}, + {files,["/Users/stavros.aronis/git/Concuerror/tests/suites/basic_tests/src/safeops_coverage.erl"]}, + {first_process_errors_only,false}, + {ignore_error,[]}, + {instant_delivery,true}, + {interleaving_bound,infinity}, + {keep_going,true}, + {non_racing_system,[]}, + {print_depth,20}, + {quiet,true}, + {scheduling,round_robin}, + {scheduling_bound_type,none}, + {show_races,false}, + {strict_scheduling,false}, + {symbolic_names,true}, + {timeout,5000}, + {treat_as_normal,[]}, + {use_receive_patterns,true}] +################################################################################ +Exploration completed! + No errors found! +################################################################################ +Tips: +-------------------------------------------------------------------------------- +* Check `--help attributes' for info on how to pass options via module attributes. +* Running without a scheduling_bound corresponds to verification and may take a long time. + +################################################################################ +Info: +-------------------------------------------------------------------------------- +* Writing results in /Users/stavros.aronis/git/Concuerror/tests/results/basic_tests/results/safeops_coverage-test-inf-optimal.txt +* Automatically instrumented module io_lib +* Showing PIDs as "" ('-h symbolic_names'). +* Instrumented & loaded module safeops_coverage +* Automatically instrumented module erlang + +################################################################################ +Done at 21 Aug 2018 10:17:50 (Exit status: ok) + Summary: 0 errors, 1/1 interleavings explored diff --git a/tests/suites/basic_tests/src/safeops_coverage.erl b/tests/suites/basic_tests/src/safeops_coverage.erl new file mode 100644 index 000000000..8735856ca --- /dev/null +++ b/tests/suites/basic_tests/src/safeops_coverage.erl @@ -0,0 +1,21 @@ +-module(safeops_coverage). + +-compile(export_all). + +scenarios() -> + [ test + ]. + +test() -> + erlang:adler32("42"), + [1, 2, 3, 4] = erlang:append([1, 2], [3, 4]), + erlang:bump_reductions(10), + erlang:crc32("42"), + erlang:decode_packet(raw, <<"foo">>, []), + {c} = erlang:delete_element(1, {b, c}), + erlang:external_size(42), + erlang:garbage_collect(), + {b, c} = erlang:insert_element(1, {c}, b), + true = erlang:is_builtin(erlang, is_builtin, 3), + {a, a, a} = erlang:make_tuple(3, a), + [1, 2] = erlang:subtract([1, 2, 3], [3]). From a1d6bbaecc204826f036b7739bbd7042dec24d99 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Tue, 21 Aug 2018 10:44:58 +0200 Subject: [PATCH 5/6] Fix dependencies for proc_info message* --- src/concuerror_callback.erl | 9 +- src/concuerror_dependencies.erl | 10 +- ...s_info-test_message_queue_len-inf-dpor.txt | 485 ++++++++++++++++++ .../process_info-test_messages-inf-dpor.txt | 117 +++++ .../process_info-test_mql_flush-inf-dpor.txt | 151 ++++++ tests/suites/basic_tests/src/process_info.erl | 55 +- 6 files changed, 820 insertions(+), 7 deletions(-) create mode 100644 tests/suites/basic_tests/results/process_info-test_message_queue_len-inf-dpor.txt create mode 100644 tests/suites/basic_tests/results/process_info-test_messages-inf-dpor.txt create mode 100644 tests/suites/basic_tests/results/process_info-test_mql_flush-inf-dpor.txt diff --git a/src/concuerror_callback.erl b/src/concuerror_callback.erl index 27682cecf..50bca882d 100644 --- a/src/concuerror_callback.erl +++ b/src/concuerror_callback.erl @@ -678,8 +678,13 @@ run_built_in(erlang, process_info, 2, [Pid, Item], Info) when is_atom(Item) -> catch error:badarg -> [] end; messages -> - #concuerror_info{message_queue = Queue} = TheirInfo, - [M || #message{data = M} <- queue:to_list(Queue)]; + #concuerror_info{logger = Logger} = TheirInfo, + Msg = + "Concuerror does not properly support" + " erlang:process_info(Other, messages)," + " returning an empty list instead.~n", + ?unique(Logger, ?lwarning, Msg, []), + []; message_queue_len -> #concuerror_info{message_queue = Queue} = TheirInfo, queue:len(Queue); diff --git a/src/concuerror_dependencies.erl b/src/concuerror_dependencies.erl index e1027776b..455012412 100644 --- a/src/concuerror_dependencies.erl +++ b/src/concuerror_dependencies.erl @@ -393,14 +393,17 @@ dependent_process_info(#builtin_event{mfargs = {_,_,[Pid, links]}}, when UnLink =:= link; UnLink =:= unlink -> true; _ -> false end; -dependent_process_info(#builtin_event{mfargs = {_,_,[Pid, Msg]}}, - Other) - when Msg =:= messages; Msg =:= message_queue_len -> +dependent_process_info(#builtin_event{mfargs = {_,_,[Pid, message_queue_len]}}, + Other) -> case Other of #message_event{recipient = Recipient} -> Recipient =:= Pid; #receive_event{recipient = Recipient, message = M} -> Recipient =:= Pid andalso M =/= 'after'; + #builtin_event{actor = Recipient, mfargs = {M, F, [_, Args]}} -> + Recipient =:= Pid andalso + {M, F} =:= {erlang, demonitor} andalso + try lists:member(flush, Args) catch _:_ -> false end; _ -> false end; dependent_process_info(#builtin_event{mfargs = {_, _, [Pid, registered_name]}}, @@ -431,6 +434,7 @@ dependent_process_info(#builtin_event{mfargs = {_,_,[_, Safe]}}, Safe =:= current_stacktrace; Safe =:= dictionary; Safe =:= heap_size; + Safe =:= messages; %% If fixed, it should be an observer of message races Safe =:= reductions; Safe =:= stack_size; Safe =:= status diff --git a/tests/suites/basic_tests/results/process_info-test_message_queue_len-inf-dpor.txt b/tests/suites/basic_tests/results/process_info-test_message_queue_len-inf-dpor.txt new file mode 100644 index 000000000..747ee2754 --- /dev/null +++ b/tests/suites/basic_tests/results/process_info-test_message_queue_len-inf-dpor.txt @@ -0,0 +1,485 @@ +Concuerror AFS2018+build.2177.ref65f5340 started at 21 Aug 2018 12:15:41 + Options: + [{after_timeout,infinity}, + {assertions_only,false}, + {assume_racing,false}, + {depth_bound,500}, + {disable_sleep_sets,false}, + {dpor,optimal}, + {entry_point,{process_info,test_message_queue_len,[]}}, + {exclude_module,[]}, + {files,["/Users/stavros.aronis/git/Concuerror/tests/suites/basic_tests/src/process_info.erl"]}, + {first_process_errors_only,false}, + {ignore_error,[]}, + {instant_delivery,true}, + {interleaving_bound,infinity}, + {keep_going,true}, + {non_racing_system,[]}, + {print_depth,20}, + {quiet,true}, + {scheduling,round_robin}, + {scheduling_bound_type,none}, + {show_races,false}, + {strict_scheduling,false}, + {symbolic_names,true}, + {timeout,5000}, + {treat_as_normal,[]}, + {use_receive_patterns,true}] +################################################################################ +Interleaving #1 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 47 + 8: : exits normally + 9: : {ok,} = ! {ok,} + in process_info.erl line 51 + 10: : exits normally + 11: : [{message_queue_len,3}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Interleaving #2 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 47 + 8: : exits normally + 9: : {ok,} = ! {ok,} + in process_info.erl line 51 + 10: : exits normally + 11: : receives message ({ok,}) + in process_info.erl line 40 + 12: : [{message_queue_len,2}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 13: : exits normally +################################################################################ +Interleaving #3 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 47 + 8: : exits normally + 9: : [{message_queue_len,2}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 10: : exits normally + 11: : receives message ({ok,}) + in process_info.erl line 40 + 12: : {ok,} = ! {ok,} + in process_info.erl line 51 + 13: : exits normally +################################################################################ +Interleaving #4 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 47 + 8: : exits normally + 9: : receives message ({ok,}) + in process_info.erl line 40 + 10: : [{message_queue_len,1}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 11: : exits normally + 12: : {ok,} = ! {ok,} + in process_info.erl line 51 + 13: : exits normally +################################################################################ +Interleaving #5 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 51 + 8: : {ok,} = ! {ok,} + in process_info.erl line 47 + 9: : exits normally + 10: : exits normally + 11: : [{message_queue_len,3}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Interleaving #6 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 51 + 8: : {ok,} = ! {ok,} + in process_info.erl line 47 + 9: : exits normally + 10: : exits normally + 11: : receives message ({ok,}) + in process_info.erl line 40 + 12: : [{message_queue_len,2}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 13: : exits normally +################################################################################ +Interleaving #7 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 51 + 8: : exits normally + 9: : [{message_queue_len,2}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 10: : exits normally + 11: : receives message ({ok,}) + in process_info.erl line 40 + 12: : {ok,} = ! {ok,} + in process_info.erl line 47 + 13: : exits normally +################################################################################ +Interleaving #8 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 51 + 8: : exits normally + 9: : receives message ({ok,}) + in process_info.erl line 40 + 10: : [{message_queue_len,1}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 11: : exits normally + 12: : {ok,} = ! {ok,} + in process_info.erl line 47 + 13: : exits normally +################################################################################ +Interleaving #9 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : [{message_queue_len,1}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 8: : exits normally + 9: : {ok,} = ! {ok,} + in process_info.erl line 47 + 10: : exits normally + 11: : {ok,} = ! {ok,} + in process_info.erl line 51 + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Interleaving #10 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : [{message_queue_len,1}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 8: : exits normally + 9: : {ok,} = ! {ok,} + in process_info.erl line 51 + 10: : {ok,} = ! {ok,} + in process_info.erl line 47 + 11: : exits normally + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Interleaving #11 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {ok,} = ! {ok,} + in process_info.erl line 51 + 7: : exits normally + 8: : [{message_queue_len,1}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 9: : exits normally + 10: : receives message ({ok,}) + in process_info.erl line 40 + 11: : {bar,} = ! {bar,} + in process_info.erl line 46 + 12: : {ok,} = ! {ok,} + in process_info.erl line 47 + 13: : exits normally +################################################################################ +Interleaving #12 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {ok,} = ! {ok,} + in process_info.erl line 51 + 7: : exits normally + 8: : receives message ({ok,}) + in process_info.erl line 40 + 9: : [{message_queue_len,0}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 10: : exits normally + 11: : {bar,} = ! {bar,} + in process_info.erl line 46 + 12: : {ok,} = ! {ok,} + in process_info.erl line 47 + 13: : exits normally +################################################################################ +Interleaving #13 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : [{message_queue_len,0}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 7: : exits normally + 8: : {bar,} = ! {bar,} + in process_info.erl line 46 + 9: : {ok,} = ! {ok,} + in process_info.erl line 47 + 10: : exits normally + 11: : {ok,} = ! {ok,} + in process_info.erl line 51 + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Interleaving #14 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : [{message_queue_len,0}] = erlang:process_info(, [message_queue_len]) + in process_info.erl line 57 + 7: : exits normally + 8: : {bar,} = ! {bar,} + in process_info.erl line 46 + 9: : {ok,} = ! {ok,} + in process_info.erl line 51 + 10: : {ok,} = ! {ok,} + in process_info.erl line 47 + 11: : exits normally + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Exploration completed! +################################################################################ +Tips: +-------------------------------------------------------------------------------- +* Check `--help attributes' for info on how to pass options via module attributes. +* Running without a scheduling_bound corresponds to verification and may take a long time. +* Increase '--print_depth' if output/graph contains "...". +* Each of the first 10 interleavings explored so far had some error. This can make later debugging difficult, as the generated report will include too much info. Consider refactoring your code, or using the appropriate options to filter out irrelevant errors. + +################################################################################ +Info: +-------------------------------------------------------------------------------- +* Writing results in /Users/stavros.aronis/git/Concuerror/tests/results/basic_tests/results/process_info-test_message_queue_len-inf-dpor.txt +* Automatically instrumented module io_lib +* Showing PIDs as "" ('-h symbolic_names'). +* Instrumented & loaded module process_info +* Automatically instrumented module erlang +* Continuing after error (-k) +* You can see pairs of racing instructions (in the report and '--graph') with '--show_races true' + +################################################################################ +Done at 21 Aug 2018 12:15:41 (Exit status: error) + Summary: 14 errors, 14/14 interleavings explored diff --git a/tests/suites/basic_tests/results/process_info-test_messages-inf-dpor.txt b/tests/suites/basic_tests/results/process_info-test_messages-inf-dpor.txt new file mode 100644 index 000000000..c84754e6a --- /dev/null +++ b/tests/suites/basic_tests/results/process_info-test_messages-inf-dpor.txt @@ -0,0 +1,117 @@ +Concuerror AFS2018+build.2177.ref65f5340 started at 21 Aug 2018 12:15:37 + Options: + [{after_timeout,infinity}, + {assertions_only,false}, + {assume_racing,false}, + {depth_bound,500}, + {disable_sleep_sets,false}, + {dpor,optimal}, + {entry_point,{process_info,test_messages,[]}}, + {exclude_module,[]}, + {files,["/Users/stavros.aronis/git/Concuerror/tests/suites/basic_tests/src/process_info.erl"]}, + {first_process_errors_only,false}, + {ignore_error,[]}, + {instant_delivery,true}, + {interleaving_bound,infinity}, + {keep_going,true}, + {non_racing_system,[]}, + {print_depth,20}, + {quiet,true}, + {scheduling,round_robin}, + {scheduling_bound_type,none}, + {show_races,false}, + {strict_scheduling,false}, + {symbolic_names,true}, + {timeout,5000}, + {treat_as_normal,[]}, + {use_receive_patterns,true}] +################################################################################ +Interleaving #1 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : {ok,} = ! {ok,} + in process_info.erl line 47 + 8: : exits normally + 9: : {ok,} = ! {ok,} + in process_info.erl line 51 + 10: : exits normally + 11: : [{messages,[]}] = erlang:process_info(, [messages]) + in process_info.erl line 57 + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Interleaving #2 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 41 + Mailbox contents: [{bar,},{ok,}] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 4:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 5:

: exits normally + 6: : {bar,} = ! {bar,} + in process_info.erl line 46 + 7: : [{messages,[]}] = erlang:process_info(, [messages]) + in process_info.erl line 57 + 8: : exits normally + 9: : {ok,} = ! {ok,} + in process_info.erl line 51 + 10: : {ok,} = ! {ok,} + in process_info.erl line 47 + 11: : exits normally + 12: : exits normally + 13: : receives message ({ok,}) + in process_info.erl line 40 +################################################################################ +Exploration completed! +################################################################################ +Warnings: +-------------------------------------------------------------------------------- +* Concuerror does not properly support erlang:process_info(Other, messages), returning an empty list instead. + +################################################################################ +Tips: +-------------------------------------------------------------------------------- +* Check `--help attributes' for info on how to pass options via module attributes. +* Running without a scheduling_bound corresponds to verification and may take a long time. +* Increase '--print_depth' if output/graph contains "...". + +################################################################################ +Info: +-------------------------------------------------------------------------------- +* Writing results in /Users/stavros.aronis/git/Concuerror/tests/results/basic_tests/results/process_info-test_messages-inf-dpor.txt +* Automatically instrumented module io_lib +* Showing PIDs as "" ('-h symbolic_names'). +* Instrumented & loaded module process_info +* Automatically instrumented module erlang +* Continuing after error (-k) +* You can see pairs of racing instructions (in the report and '--graph') with '--show_races true' + +################################################################################ +Done at 21 Aug 2018 12:15:37 (Exit status: error) + Summary: 2 errors, 2/2 interleavings explored diff --git a/tests/suites/basic_tests/results/process_info-test_mql_flush-inf-dpor.txt b/tests/suites/basic_tests/results/process_info-test_mql_flush-inf-dpor.txt new file mode 100644 index 000000000..b42fe5674 --- /dev/null +++ b/tests/suites/basic_tests/results/process_info-test_mql_flush-inf-dpor.txt @@ -0,0 +1,151 @@ +Concuerror AFS2018+build.2178.ref4861cf2 started at 21 Aug 2018 13:56:25 + Options: + [{after_timeout,infinity}, + {assertions_only,false}, + {assume_racing,false}, + {depth_bound,500}, + {disable_sleep_sets,false}, + {dpor,optimal}, + {entry_point,{process_info,test_mql_flush,[]}}, + {exclude_module,[]}, + {files,["/Users/stavros.aronis/git/Concuerror/tests/suites/basic_tests/src/process_info.erl"]}, + {first_process_errors_only,false}, + {ignore_error,[]}, + {instant_delivery,true}, + {interleaving_bound,infinity}, + {keep_going,true}, + {non_racing_system,[]}, + {print_depth,20}, + {quiet,true}, + {scheduling,round_robin}, + {scheduling_bound_type,none}, + {show_races,false}, + {strict_scheduling,false}, + {symbolic_names,true}, + {timeout,5000}, + {treat_as_normal,[]}, + {use_receive_patterns,true}] +################################################################################ +Interleaving #1 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 67 + Mailbox contents: [] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: exits normally + 4: : {,#Ref<0.4212114868.2148532225.166955>} = erlang:spawn_opt({erlang,apply,[#Fun,[]],[monitor]}) + in erlang.erl line 2731 + 5: : true = erlang:demonitor(#Ref<0.4212114868.2148532225.166955>, [flush]) + in process_info.erl line 66 + 6: : {message_queue_len,0} = erlang:process_info(, message_queue_len) + in process_info.erl line 72 + 7: : exits normally + 8: : exits normally + 9: : {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal} = erlang:send(, {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal}) + (while exiting) +################################################################################ +Interleaving #2 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 67 + Mailbox contents: [] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: exits normally + 4: : {,#Ref<0.4212114868.2148532225.166955>} = erlang:spawn_opt({erlang,apply,[#Fun,[]],[monitor]}) + in erlang.erl line 2731 + 5: : true = erlang:demonitor(#Ref<0.4212114868.2148532225.166955>, [flush]) + in process_info.erl line 66 + 6: : exits normally + 7: : {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal} = erlang:send(, {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal}) + (while exiting) + 8: : {message_queue_len,0} = erlang:process_info(, message_queue_len) + in process_info.erl line 72 + 9: : exits normally +################################################################################ +Interleaving #3 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 67 + Mailbox contents: [] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: exits normally + 4: : {,#Ref<0.4212114868.2148532225.166955>} = erlang:spawn_opt({erlang,apply,[#Fun,[]],[monitor]}) + in erlang.erl line 2731 + 5: : exits normally + 6: : {message_queue_len,0} = erlang:process_info(, message_queue_len) + in process_info.erl line 72 + 7: : exits normally + 8: : {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal} = erlang:send(, {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal}) + (while exiting) + 9: : true = erlang:demonitor(#Ref<0.4212114868.2148532225.166955>, [flush]) + in process_info.erl line 66 +################################################################################ +Interleaving #4 +-------------------------------------------------------------------------------- +Errors found: +* Blocked at a 'receive' ("deadlocked"; other processes have exited): + in process_info.erl line 67 + Mailbox contents: [] +-------------------------------------------------------------------------------- +Event trace: + 1:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 2:

: = erlang:spawn(erlang, apply, [#Fun,[]]) + in erlang.erl line 2687 + 3:

: exits normally + 4: : {,#Ref<0.4212114868.2148532225.166955>} = erlang:spawn_opt({erlang,apply,[#Fun,[]],[monitor]}) + in erlang.erl line 2731 + 5: : exits normally + 6: : {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal} = erlang:send(, {'DOWN',#Ref<0.4212114868.2148532225.166955>,process,,normal}) + (while exiting) + 7: : {message_queue_len,1} = erlang:process_info(, message_queue_len) + in process_info.erl line 72 + 8: : exits normally + 9: : true = erlang:demonitor(#Ref<0.4212114868.2148532225.166955>, [flush]) + in process_info.erl line 66 +################################################################################ +Exploration completed! +################################################################################ +Warnings: +-------------------------------------------------------------------------------- +* Concuerror may let exiting processes emit 'DOWN' messages for cancelled monitors. Any such messages are discarded upon delivery and can never be received. + +################################################################################ +Tips: +-------------------------------------------------------------------------------- +* Check `--help attributes' for info on how to pass options via module attributes. +* Running without a scheduling_bound corresponds to verification and may take a long time. +* Increase '--print_depth' if output/graph contains "...". + +################################################################################ +Info: +-------------------------------------------------------------------------------- +* Writing results in /Users/stavros.aronis/git/Concuerror/tests/results/basic_tests/results/process_info-test_mql_flush-inf-dpor.txt +* Automatically instrumented module io_lib +* Showing PIDs as "" ('-h symbolic_names'). +* Instrumented & loaded module process_info +* Automatically instrumented module erlang +* Continuing after error (-k) +* You can see pairs of racing instructions (in the report and '--graph') with '--show_races true' + +################################################################################ +Done at 21 Aug 2018 13:56:26 (Exit status: error) + Summary: 4 errors, 4/4 interleavings explored diff --git a/tests/suites/basic_tests/src/process_info.erl b/tests/suites/basic_tests/src/process_info.erl index 90d72441d..2dda3eb46 100644 --- a/tests/suites/basic_tests/src/process_info.erl +++ b/tests/suites/basic_tests/src/process_info.erl @@ -1,9 +1,16 @@ -module(process_info). -compile(export_all). --export([scenarios/0]). -scenarios() -> [{T, inf, dpor} || T <- [test1, test2, test3]]. +scenarios() -> + [{T, inf, dpor} || + T <- [ test1 + , test2 + , test3 + , test_messages + , test_message_queue_len + , test_mql_flush + ]]. test1() -> Fun = fun() -> register(foo, self()) end, @@ -21,3 +28,47 @@ test3() -> _ -> ok end, undefined = process_info(P, [registered_name, group_leader]). + +test_messages() -> + test_with_messages([messages]). + +test_message_queue_len() -> + test_with_messages([message_queue_len]). + +test_with_messages(Info) -> + Fun = + fun() -> + receive {ok, _} -> ok end, + receive after infinity -> ok end + end, + P = spawn(Fun), + Fun2 = + fun() -> + P ! {bar, self()}, + P ! {ok, self()} + end, + Fun3 = + fun() -> + P ! {ok, self()} + end, + spawn(Fun2), + spawn(Fun3), + Fun4 = + fun() -> + process_info(P, Info) + end, + spawn(Fun4). + +test_mql_flush() -> + Fun = + fun() -> + {P, M} = spawn_monitor(fun() -> ok end), + demonitor(M, [flush]), + receive after infinity -> ok end + end, + P = spawn(Fun), + Fun2 = + fun() -> + process_info(P, message_queue_len) + end, + spawn(Fun2). From 6ab7afcdba265deb51456563be3a5eba22c3cfca Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Tue, 21 Aug 2018 14:05:11 +0200 Subject: [PATCH 6/6] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7de3811bb..a05713bb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - handling of demonitors (#281) +- handling of process_info(..., messages) (#283) ### Fixed - fixed stacktrace information (#276)