Issue: Safety violation
Shared Variables Output
Turn Thread Execution
 PC 
cnt flags turn
T0: __init__()
Set flags to [ False, False ]
Choose 1
Set turn to 1
Set cnt to 0
T2: thread(1)
Choose True
Set turn to 0
T1: thread(0)
Choose True
Set turn to 1
Set flags[0] to True
Set cnt to 1
T2: thread(1)
Set flags[1] to True
Set cnt to 2

Harmony bytecode

0  Frame __init__()
1  Sequential
2  Sequential
3  Push ()
4  Push False
5  2-ary ListAdd
6  Push False
7  2-ary ListAdd
8  Store flags
9  Push {}
10  Push 0
11  2-ary SetAdd
12  Push 1
13  2-ary SetAdd
14  Choose
15  Store turn
16  Push 0
17  Store cnt
18  Jump 74
19  Frame thread(tid)
20  Push {}
21  Push False
22  2-ary SetAdd
23  Push True
24  2-ary SetAdd
25  Choose
26  JumpCond False 72
27  Push 1
28  LoadVar tid
29  2-ary -
30  Store turn
31  Push ?flags
32  LoadVar tid
33  2-ary AddArg
34  Push True
35  Store
36  Push ?flags
37  Push 1
38  LoadVar tid
39  2-ary -
40  2-ary AddArg
41  Load
42  JumpCond False 47
43  Load turn
44  LoadVar tid
45  2-ary !=
46  Jump 48
47  Push False
48  JumpCond False 50
49  Jump 36
50  Load cnt
51  Push 1
52  2-ary +
53  Store cnt
54  AtomicInc(lazy)
55  ReadonlyInc
56  Load cnt
57  Push 1
58  2-ary ==
59  Assert
60  ReadonlyDec
61  AtomicDec
62  Load cnt
63  Push 1
64  2-ary -
65  Store cnt
66  Push ?flags
67  LoadVar tid
68  2-ary AddArg
69  Push False
70  Store
71  Jump 20
72  DelVar tid
73  ReturnOp(result. None)
74  Push ?PC(19)
75  Push 0
76  2-ary AddArg
77  Push {:}
78  Spawn
79  Push ?PC(19)
80  Push 1
81  2-ary AddArg
82  Push {:}
83  Spawn
84  ReturnOp(result. None)
85  DelVar result
Threads
 ID   Status  Stack Trace  Stack Top 
T0 init
T1 init
T2 init