Showing error 1376

User: Jiri Slaby
Error type: Reachable Error Location
Error type description: A specified error location is reachable in some program path
File location: ldv-regression/mutex_lock_struct.c_safe_1.i
Line in file: 15
Project: SV-COMP 2013
Project version: 2.6.28
Tools: Manual Work
Entered: 2013-01-17 16:57:54 UTC


Source:

 1# 1 "files/mutex_lock_struct.c"
 2# 1 "<built-in>"
 3# 1 "<command-line>"
 4# 1 "files/mutex_lock_struct.c"
 5
 6
 7
 8
 9
10
11
12
13
14void err()
15{ ERROR: goto ERROR; }
16
17struct mutex {
18 int is_locked;
19};
20
21void mutex_lock(struct mutex *a)
22{
23 if (a->is_locked == 1) err();
24 a->is_locked = 1;
25}
26
27void mutex_unlock(struct mutex *b)
28{
29 if (b->is_locked != 1) err();
30 b->is_locked = 0;
31}
32
33int main()
34{
35 struct mutex m;
36 m.is_locked = 0;
37
38 mutex_lock(&m);
39
40 mutex_unlock(&m);
41
42
43
44
45}