Browse files

Receive statements may have guards

If the guard is not taken into account we may assume that a receive statement
is unblocked when it in fact it is not.
  • Loading branch information...
1 parent 52c50ca commit b8ab15f6c5a5427feae7e9ecb36f1937e733ffed @aronisstav aronisstav committed Jun 25, 2013
View
3 src/concuerror_instr.erl
@@ -607,8 +607,9 @@ transform_receive_case(Clauses) ->
Fun =
fun(Clause) ->
[Pattern] = erl_syntax:clause_patterns(Clause),
+ Guard = erl_syntax:clause_guard(Clause),
NewBody = erl_syntax:atom(continue),
- erl_syntax:clause([Pattern], [], [NewBody])
+ erl_syntax:clause([Pattern], Guard, [NewBody])
end,
NewClauses = lists:map(Fun, Clauses),
Pattern = new_underscore_variable(),
View
10 testsuite/suites/dpor/results/receive_with_guard-receive_with_guard-inf-dpor.txt
@@ -0,0 +1,10 @@
+Checked 1 interleaving(s). 1 errors found.
+
+1
+Error type : Deadlock
+Blocked processes : P1.1
+ Process P1 spawns process P1.1
+ Process P1 sends message `10` to process P1.1
+ Process P1 exits (normal)
+
+
View
15 testsuite/suites/dpor/src/receive_with_guard.erl
@@ -0,0 +1,15 @@
+-module(receive_with_guard).
+
+-export([receive_with_guard/0]).
+-export([scenarios/0]).
+
+scenarios() -> [{?MODULE, inf, dpor}].
+
+receive_with_guard() ->
+ P1 =
+ spawn(fun() ->
+ receive
+ W when is_atom(W) -> ok
+ end
+ end),
+ P1 ! 10.

0 comments on commit b8ab15f

Please sign in to comment.