Browse files

Fix spawn_opts when 'monitor' is an opt

  • Loading branch information...
1 parent 7788fde commit 20b045d1e85d37b4cd59efa6571307b057a1a207 @aronisstav aronisstav committed Jun 5, 2013
View
8 src/concuerror_proc_action.erl
@@ -192,10 +192,14 @@ to_string({spawn_monitor, Parent, Child}) ->
[concuerror_lid:to_string(Parent),
concuerror_lid:to_string(Child)]);
to_string({spawn_opt, not_found, Child}) ->
- io_lib:format("Unknown process spawns with opts to process ~s",
+ io_lib:format("Unknown process spawns process ~s with opts",
[concuerror_lid:to_string(Child)]);
+to_string({spawn_opt, Parent, {Child, _Ref}}) ->
+ io_lib:format("Process ~s spawns process ~s with opts (and monitors)",
+ [concuerror_lid:to_string(Parent),
+ concuerror_lid:to_string(Child)]);
to_string({spawn_opt, Parent, Child}) ->
- io_lib:format("Process ~s spawns with opts to process ~s",
+ io_lib:format("Process ~s spawns process ~s with opts",
[concuerror_lid:to_string(Parent),
concuerror_lid:to_string(Child)]);
to_string({unlink, Proc, not_found}) ->
View
18 src/concuerror_rep.erl
@@ -483,13 +483,19 @@ spawn_center(Kind, Fun) ->
check_unknown_process(),
Spawner =
case Kind of
+ {spawn_opt, Opt} -> fun(F) -> spawn_opt(F, Opt) end;
spawn -> fun spawn/1;
spawn_link -> fun spawn_link/1;
spawn_monitor -> fun spawn_monitor/1
end,
- concuerror_sched:notify(Kind, unknown),
+ {Tag, Info} =
+ case Kind of
+ {spawn_opt, _} = S -> S;
+ _ -> {Kind, unknown}
+ end,
+ concuerror_sched:notify(Tag, Info),
Result = Spawner(fun() -> spawn_fun_wrapper(Fun) end),
- concuerror_sched:notify(Kind, Result, prev),
+ concuerror_sched:notify(Tag, Result, prev),
%% Wait before using the PID to be sure that an LID is assigned
concuerror_sched:wait(),
Result.
@@ -629,13 +635,7 @@ rep_spawn_monitor(Module, Function, Args) ->
{'min_bin_vheap_size', integer()}]) ->
pid() | {pid(), reference()}.
rep_spawn_opt(Fun, Opt) ->
- check_unknown_process(),
- concuerror_sched:notify(spawn_opt, unknown),
- Result = spawn_opt(fun() -> spawn_fun_wrapper(Fun) end, Opt),
- concuerror_sched:notify(spawn_opt, Result, prev),
- %% Wait before using the PID to be sure that an LID is assigned
- concuerror_sched:wait(),
- Result.
+ spawn_center({spawn_opt, Opt}, Fun).
%% @spec rep_spawn_opt(atom(), atom(), [term()],
%% ['link' | 'monitor' |
View
2 testsuite/suites/resources/results/sched_tests-test_spawn_opt_link_receive_exit-0-dpor.txt
@@ -3,7 +3,7 @@ Checked 1 interleaving(s). 1 errors found.
1
Error type : Deadlock
Blocked processes : P1.1
- Process P1 spawns with opts to process P1.1
+ Process P1 spawns process P1.1 with opts
Process P1 exits (normal)
Process P1.1 sets flag `trap_exit` to `true`
Process P1.1 blocks
View
2 testsuite/suites/resources/results/sched_tests-test_spawn_opt_link_receive_exit-0.txt
@@ -3,7 +3,7 @@ Checked 1 interleaving(s). 1 errors found.
1
Error type : Deadlock
Blocked processes : P1.1
- Process P1 spawns with opts to process P1.1
+ Process P1 spawns process P1.1 with opts
Process P1 exits (normal)
Process P1.1 sets flag `trap_exit` to `true`
Process P1.1 blocks
View
2 testsuite/suites/resources/results/sched_tests-test_spawn_opt_link_receive_exit-1-dpor.txt
@@ -3,7 +3,7 @@ Checked 2 interleaving(s). 1 errors found.
1
Error type : Deadlock
Blocked processes : P1.1
- Process P1 spawns with opts to process P1.1
+ Process P1 spawns process P1.1 with opts
Process P1 exits (normal)
Process P1.1 sets flag `trap_exit` to `true`
Process P1.1 blocks
View
2 testsuite/suites/resources/results/sched_tests-test_spawn_opt_link_receive_exit-1.txt
@@ -3,7 +3,7 @@ Checked 2 interleaving(s). 1 errors found.
1
Error type : Deadlock
Blocked processes : P1.1
- Process P1 spawns with opts to process P1.1
+ Process P1 spawns process P1.1 with opts
Process P1 exits (normal)
Process P1.1 sets flag `trap_exit` to `true`
Process P1.1 blocks
View
2 testsuite/suites/resources/results/sched_tests-test_spawn_opt_link_receive_exit-inf-dpor.txt
@@ -3,7 +3,7 @@ Checked 2 interleaving(s). 1 errors found.
1
Error type : Deadlock
Blocked processes : P1.1
- Process P1 spawns with opts to process P1.1
+ Process P1 spawns process P1.1 with opts
Process P1 exits (normal)
Process P1.1 sets flag `trap_exit` to `true`
Process P1.1 blocks
View
2 testsuite/suites/resources/results/sched_tests-test_spawn_opt_link_receive_exit-inf.txt
@@ -3,7 +3,7 @@ Checked 2 interleaving(s). 1 errors found.
1
Error type : Deadlock
Blocked processes : P1.1
- Process P1 spawns with opts to process P1.1
+ Process P1 spawns process P1.1 with opts
Process P1 exits (normal)
Process P1.1 sets flag `trap_exit` to `true`
Process P1.1 blocks
View
12 testsuite/suites/resources/results/sched_tests-test_spawn_opt_monitor-0-dpor.txt
@@ -1 +1,11 @@
-Checked 1 interleaving(s). No errors found.
+Checked 1 interleaving(s). 1 errors found.
+
+1
+Error type : Deadlock
+Blocked processes : P1
+ Process P1 spawns process P1.1 with opts (and monitors)
+ Process P1 demonitors process P1.1
+ Process P1 blocks
+ Process P1.1 exits (normal)
+
+
View
12 testsuite/suites/resources/results/sched_tests-test_spawn_opt_monitor-0.txt
@@ -1 +1,11 @@
-Checked 1 interleaving(s). No errors found.
+Checked 1 interleaving(s). 1 errors found.
+
+1
+Error type : Deadlock
+Blocked processes : P1
+ Process P1 spawns process P1.1 with opts (and monitors)
+ Process P1 demonitors process P1.1
+ Process P1 blocks
+ Process P1.1 exits (normal)
+
+
View
12 testsuite/suites/resources/results/sched_tests-test_spawn_opt_monitor-inf-dpor.txt
@@ -1 +1,11 @@
-Checked 1 interleaving(s). No errors found.
+Checked 2 interleaving(s). 1 errors found.
+
+1
+Error type : Deadlock
+Blocked processes : P1
+ Process P1 spawns process P1.1 with opts (and monitors)
+ Process P1 demonitors process P1.1
+ Process P1 blocks
+ Process P1.1 exits (normal)
+
+
View
12 testsuite/suites/resources/results/sched_tests-test_spawn_opt_monitor-inf.txt
@@ -1 +1,11 @@
-Checked 1 interleaving(s). No errors found.
+Checked 2 interleaving(s). 1 errors found.
+
+1
+Error type : Deadlock
+Blocked processes : P1
+ Process P1 spawns process P1.1 with opts (and monitors)
+ Process P1 demonitors process P1.1
+ Process P1 blocks
+ Process P1.1 exits (normal)
+
+
View
1 testsuite/suites/resources/src/sched_tests.erl
@@ -470,6 +470,7 @@ test_spawn_opt_link_receive_exit() ->
test_spawn_opt_monitor() ->
{Pid, Ref} = spawn_opt(fun() -> ok end, [monitor]),
+ demonitor(Ref),
receive
{'DOWN', Ref, process, Pid, normal} -> ok
end.

0 comments on commit 20b045d

Please sign in to comment.