Search code examples
verificationspin

Spin verifying properties related to channels


I created a simple model in Spin in which two processes S send messages to another process R. Process R then sends responses to both processes. I would like to define the property "if process x sends a message, then process y eventually receives it", as shown below. The problem is that although the simulation is working as expected, verification is not. The property I defined at line 9 is always passing without errors although I injected a fault at line 17 that should make verification fail. Am I missing something here?

1   byte r1PId;
2   byte s1PId;
3   byte s2PId;
4   
5   byte nextM = 1;
6   
7   chan toS[2] = [2] of {byte};
8   
9   ltl p1 {[] ((s[s1PId]:m > 0) -> <>(s[s1PId]:m == r:m))}
10  
11  proctype r(byte id; chan stoR)
12  {
13      do
14      :: true
15      byte c; byte m; byte m2;
16      stoR?c, m2;
17      m = 67; //should be m = m2
18  
19      byte response = 50;
20  
21      toS[c]!response;
22      od
23  }
24  
25  proctype s(byte id; chan rtoS; chan stoR)
26  {
27      byte m;
28      atomic
29      {
30          m = nextM;
31          nextM = nextM+1;
32      }
33      stoR!id, m;
34      byte response;
35      rtoS?response;  
36  }
37  
38  init{
39     chan toR = [10] of {byte, byte};
40     r1PId = run r(10, toR);
41     s1PId = run s(0, toS[0], toR);
42     s2PId = run s(1, toS[1], toR);
43  }

Solution

  • There seems to be a scope problem. When the process s terminates, its local variables will be out of scope. In that case, the reference s[s1PId]:m will be 0.

    On the other hand, in the process r, the variable m is declared inside a block. It is initialized to 0 every time before stoR?c, m2. As a result, the reference r:m will always be 0 after receiving messages twice.

    So, <>(s[s1PId]:m == r:m) will always be true.

    To quick fix this, you can either (i) move the declaration byte m in r outside the loop; or (ii) add an infinite loop in s to prevent its termination.