Permalink
Browse files

Fix a bug with exit status

Fix a bug where a process exiting with status other than normal
(currently the only alternative can be shutdown) was returing
normal as an exit status.
  • Loading branch information...
1 parent 8898618 commit 830a1184b61a0f6fa92fad554abc6099f150032c @iliastsi iliastsi committed Jun 28, 2013
View
5 src/concuerror_rep.erl
@@ -530,9 +530,10 @@ spawn_fun_wrapper(Fun) ->
Normal=:=shutdown orelse
Normal=:={shutdown, peer_close}) ->
MyInfo = find_my_info(),
- concuerror_sched:notify(exit, {normal, MyInfo}),
+ concuerror_sched:notify(exit, {Normal, MyInfo}),
MyRealInfo = find_my_info(),
- concuerror_sched:notify(exit, {normal, MyRealInfo}, prev);
+ concuerror_sched:notify(exit, {Normal, MyRealInfo}, prev),
+ exit(Normal);
Class:Type ->
concuerror_sched:notify(error,[Class,Type,erlang:get_stacktrace()])
end.
View
4 src/concuerror_sched.erl
@@ -1225,12 +1225,12 @@ replay_trace_aux([TraceState|Rest], Acc) ->
%% -----------------------------------------------------------------------------
-wait_next(Lid, {exit, {normal, _Info}} = Arg2) ->
+wait_next(Lid, {exit, {Reason, _Info}} = Arg2) ->
Pid = concuerror_lid:get_pid(Lid),
link(Pid),
continue(Lid),
receive
- {'EXIT', Pid, normal} -> {Lid, exited, []}
+ {'EXIT', Pid, Reason} -> {Lid, exited, []}
after
?TIME_LIMIT -> error(time_limit, [Lid, Arg2])
end;
View
1 testsuite/suites/regress/results/exit_shutdown-check_exit2_status-inf-dpor.txt
@@ -0,0 +1 @@
+Checked 1 interleaving(s). No errors found.
View
1 testsuite/suites/regress/results/exit_shutdown-check_exit2_status-inf.txt
@@ -0,0 +1 @@
+Checked 1 interleaving(s). No errors found.
View
1 testsuite/suites/regress/results/exit_shutdown-check_exit_status-inf-dpor.txt
@@ -0,0 +1 @@
+Checked 1 interleaving(s). No errors found.
View
1 testsuite/suites/regress/results/exit_shutdown-check_exit_status-inf.txt
@@ -0,0 +1 @@
+Checked 1 interleaving(s). No errors found.
View
21 testsuite/suites/regress/src/exit_shutdown.erl
@@ -13,10 +13,12 @@
-module(exit_shutdown).
-export([scenarios/0]).
--export([shutdown/0, terminate/0]).
+-export([shutdown/0, terminate/0, check_exit_status/0, check_exit2_status/0]).
scenarios() ->
- [ {F, inf, D} || F <- [shutdown, terminate], D <- [full, dpor] ].
+ [ {F, inf, D} ||
+ F <- [shutdown, terminate, check_exit_status, check_exit2_status],
+ D <- [full, dpor] ].
shutdown() ->
%% Spawn a process that just waits.
@@ -31,3 +33,18 @@ terminate() ->
%% Send an exit signal with status terminate to Pid.
%% This exit code should be interpreted by Concuerror as error.
exit(Pid, terminate).
+
+check_exit_status() ->
+ {Pid, Ref} = spawn_monitor(fun() -> exit(shutdown) end),
+ receive
+ {'DOWN', Ref, process, Pid, shutdown} ->
+ ok
+ end.
+
+check_exit2_status() ->
+ {Pid, Ref} = spawn_monitor(fun() -> receive ok -> ok end end),
+ exit(Pid, shutdown),
+ receive
+ {'DOWN', Ref, process, Pid, shutdown} ->
+ ok
+ end.

0 comments on commit 830a118

Please sign in to comment.