Skip to content

Commit 2958148

Browse files
Merge pull request #1399 from goblint/lockcentered_tid
Ego-Lane-Derived-Digests for Privatizations: `Lock- ` & `Write-Centered` Privatizations
2 parents cc0a268 + 74a50c7 commit 2958148

File tree

11 files changed

+332
-76
lines changed

11 files changed

+332
-76
lines changed

src/analyses/basePriv.ml

Lines changed: 118 additions & 68 deletions
Large diffs are not rendered by default.

src/config/options.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,9 @@
752752
"privatization": {
753753
"title": "ana.base.privatization",
754754
"description":
755-
"Which privatization to use? none/mutex-oplus/mutex-meet/mutex-meet-tid/protection/protection-read/mine/mine-nothread/mine-W/mine-W-noinit/lock/write/write+lock",
755+
"Which privatization to use? none/mutex-oplus/mutex-meet/mutex-meet-tid/protection/protection-read/mine/mine-nothread/mine-W/mine-W-noinit/lock/lock-tid/write/write-tid/write+lock/write+lock-tid",
756756
"type": "string",
757-
"enum": ["none", "mutex-oplus", "mutex-meet", "protection", "protection-tid", "protection-atomic", "protection-read", "protection-read-tid", "protection-read-atomic", "mine", "mine-nothread", "mine-W", "mine-W-noinit", "lock", "write", "write+lock","mutex-meet-tid"],
757+
"enum": ["none", "mutex-oplus", "mutex-meet", "protection", "protection-tid", "protection-atomic", "protection-read", "protection-read-tid", "protection-read-atomic", "mine", "mine-nothread", "mine-W", "mine-W-noinit", "lock", "lock-tid", "write", "write-tid", "write+lock", "write+lock-tid", "mutex-meet-tid"],
758758
"default": "protection-read"
759759
},
760760
"priv": {

tests/regression/13-privatized/18-first-reads.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --set ana.int.interval true
1+
// PARAM: --set ana.int.interval true --enable ana.sv-comp.functions
22
extern int __VERIFIER_nondet_int();
33

44
#include<pthread.h>

tests/regression/13-privatized/53-pfscan_widen_dependent_minimal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.int.interval --enable exp.priv-distr-init
1+
// PARAM: --enable ana.int.interval --enable exp.priv-distr-init --enable ana.sv-comp.functions
22
extern int __VERIFIER_nondet_int();
33

44
#include <pthread.h>

tests/regression/13-privatized/55-widen-dependent-local.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.int.interval --enable exp.priv-distr-init
1+
// PARAM: --enable ana.int.interval --enable exp.priv-distr-init --enable ana.sv-comp.functions
22
extern int __VERIFIER_nondet_int();
33

44
#include <pthread.h>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// PARAM: --set ana.base.privatization lock-tid --enable ana.int.interval --set ana.path_sens[+] mutex
2+
// Based on the example {e:lock-centered-beats-write-centered} from the draft of Michael Schwarz's PhD thesis.
3+
#include <pthread.h>
4+
#include <goblint.h>
5+
6+
int g;
7+
pthread_mutex_t a;
8+
pthread_mutex_t d;
9+
10+
11+
void* other()
12+
{
13+
pthread_mutex_lock(&d);
14+
pthread_mutex_lock(&a);
15+
g = 42;
16+
pthread_mutex_unlock(&a);
17+
g = 17;
18+
pthread_mutex_unlock(&d);
19+
return 0;
20+
}
21+
22+
void* there_i_ruined_it()
23+
{
24+
pthread_mutex_lock(&a);
25+
g = 45;
26+
pthread_mutex_unlock(&a);
27+
return 0;
28+
}
29+
30+
int main()
31+
{
32+
int x;
33+
pthread_t tid1;
34+
pthread_t tid2;
35+
pthread_create(&tid1, 0, other, 0);
36+
37+
pthread_mutex_lock(&d);
38+
pthread_mutex_lock(&a);
39+
pthread_mutex_unlock(&d);
40+
41+
x = g;
42+
// Succeeds with lock, fails with write
43+
// Needs the -tid variant to work here because of the there_i_ruined_it thread
44+
__goblint_check(x <= 17);
45+
46+
pthread_create(&tid2, 0, there_i_ruined_it, 0);
47+
return 0;
48+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// PARAM: --set ana.base.privatization write-tid --enable ana.int.interval --set ana.path_sens[+] mutex
2+
// Based on the example {e:write-centered} from the draft of Michael Schwarz's PhD thesis.
3+
#include <pthread.h>
4+
#include <goblint.h>
5+
6+
int g;
7+
pthread_mutex_t a;
8+
pthread_mutex_t b;
9+
pthread_mutex_t c;
10+
11+
12+
void* t1()
13+
{
14+
pthread_mutex_lock(&a);
15+
pthread_mutex_lock(&b);
16+
g = 42;
17+
pthread_mutex_unlock(&a);
18+
g = 17;
19+
pthread_mutex_unlock(&b);
20+
}
21+
22+
void* t2()
23+
{
24+
pthread_mutex_lock(&c);
25+
g = 59;
26+
pthread_mutex_unlock(&c);
27+
return 0;
28+
}
29+
30+
void* there_i_ruined_it()
31+
{
32+
pthread_mutex_lock(&a);
33+
g = 45;
34+
pthread_mutex_unlock(&a);
35+
return 0;
36+
}
37+
38+
int main()
39+
{
40+
int x;
41+
pthread_t tid1;
42+
pthread_t tid2;
43+
pthread_t tid3;
44+
45+
pthread_create(&tid1, 0, t1, 0);
46+
pthread_create(&tid2, 0, t2, 0);
47+
48+
pthread_mutex_lock(&c);
49+
g=31;
50+
pthread_mutex_lock(&a);
51+
pthread_mutex_lock(&b);
52+
53+
x = g;
54+
55+
// Succeed with write & lock
56+
__goblint_check(x >= 17);
57+
58+
// Succeeds with write-tid & lock-tid
59+
__goblint_check(x <= 42);
60+
61+
// Succeeds with write, fails with lock
62+
// Needs the -tid variant to work here because of the there_i_ruined_it thread
63+
__goblint_check(x <= 31);
64+
65+
pthread_create(&tid3, 0, there_i_ruined_it, 0);
66+
return 0;
67+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// PARAM: --set ana.base.privatization write+lock-tid --enable ana.int.interval --set ana.path_sens[+] mutex
2+
// Based on combining the examples {e:lock-centered-beats-write-centered} and {e:write-centered} from the draft of Michael Schwarz's PhD thesis.
3+
#include <pthread.h>
4+
#include <goblint.h>
5+
6+
int g;
7+
pthread_mutex_t a;
8+
pthread_mutex_t b;
9+
pthread_mutex_t c;
10+
11+
int xg;
12+
pthread_mutex_t xa;
13+
pthread_mutex_t xd;
14+
15+
16+
void* t1()
17+
{
18+
pthread_mutex_lock(&a);
19+
pthread_mutex_lock(&b);
20+
g = 42;
21+
pthread_mutex_unlock(&a);
22+
g = 17;
23+
pthread_mutex_unlock(&b);
24+
25+
pthread_mutex_lock(&xd);
26+
pthread_mutex_lock(&xa);
27+
xg = 42;
28+
pthread_mutex_unlock(&xa);
29+
xg = 17;
30+
pthread_mutex_unlock(&xd);
31+
}
32+
33+
void* t2()
34+
{
35+
pthread_mutex_lock(&c);
36+
g = 59;
37+
pthread_mutex_unlock(&c);
38+
return 0;
39+
}
40+
41+
void* there_i_ruined_it()
42+
{
43+
pthread_mutex_lock(&a);
44+
g = 45;
45+
pthread_mutex_unlock(&a);
46+
return 0;
47+
}
48+
49+
int main()
50+
{
51+
int x;
52+
int xx;
53+
pthread_t tid1;
54+
pthread_t tid2;
55+
pthread_t tid3;
56+
57+
pthread_create(&tid1, 0, t1, 0);
58+
pthread_create(&tid2, 0, t2, 0);
59+
60+
pthread_mutex_lock(&c);
61+
g=31;
62+
pthread_mutex_lock(&a);
63+
pthread_mutex_lock(&b);
64+
65+
x = g;
66+
67+
// Succeed with write & lock
68+
__goblint_check(x >= 17);
69+
70+
// Succeeds with write-tid & lock-tid
71+
__goblint_check(x <= 42);
72+
73+
// Succeeds with write, fails with lock
74+
// Needs the -tid variant to work here because of the there_i_ruined_it thread
75+
__goblint_check(x <= 31);
76+
77+
78+
pthread_mutex_lock(&xd);
79+
pthread_mutex_lock(&xa);
80+
pthread_mutex_unlock(&xd);
81+
82+
xx = xg;
83+
// Succeeds with lock, fails with write
84+
// Needs the -tid variant to work here because of the there_i_ruined_it thread
85+
__goblint_check(xx <= 17);
86+
87+
88+
89+
pthread_create(&tid3, 0, there_i_ruined_it, 0);
90+
return 0;
91+
}

tests/regression/66-interval-set-one/62-pfscan_widen_dependent_minimal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.int.interval_set --enable exp.priv-distr-init
1+
// PARAM: --enable ana.int.interval_set --enable exp.priv-distr-init --enable ana.sv-comp.functions
22
extern int __VERIFIER_nondet_int();
33

44
#include <pthread.h>

tests/regression/66-interval-set-one/98-widen-dependent-local.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.int.interval_set --enable exp.priv-distr-init
1+
// PARAM: --enable ana.int.interval_set --enable exp.priv-distr-init --enable ana.sv-comp.functions
22
extern int __VERIFIER_nondet_int();
33

44
#include <pthread.h>

0 commit comments

Comments
 (0)