-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1500 from goblint/priv-nondefinite-mutex
Fix privatization unsoundness due to non-definite and unknown mutexes
- Loading branch information
Showing
13 changed files
with
379 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// PARAM: --set ana.base.privatization protection --enable ana.sv-comp.functions | ||
#include <pthread.h> | ||
#include <goblint.h> | ||
extern _Bool __VERIFIER_nondet_bool(); | ||
|
||
int g; | ||
pthread_mutex_t m[2] = {PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}; | ||
|
||
void *t_fun(void *arg) { | ||
pthread_mutex_lock(&m[0]); | ||
pthread_mutex_lock(&m[1]); // so we're unlocking a mutex we definitely hold | ||
g++; | ||
int r = __VERIFIER_nondet_bool(); | ||
pthread_mutex_unlock(&m[r]); // TODO NOWARN (definitely held either way) | ||
// could have unlocked m[0], so should have published g there | ||
return NULL; | ||
} | ||
|
||
int main() { | ||
pthread_t id; | ||
pthread_create(&id, NULL, t_fun, NULL); | ||
|
||
pthread_mutex_lock(&m[0]); | ||
__goblint_check(g == 0); // UNKNOWN! | ||
pthread_mutex_unlock(&m[0]); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
$ goblint --set ana.base.privatization protection --enable ana.sv-comp.functions 93-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (93-unlock-idx-ambiguous.c:14:3-14:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (93-unlock-idx-ambiguous.c:24:3-24:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization mutex-meet --enable ana.sv-comp.functions 93-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (93-unlock-idx-ambiguous.c:14:3-14:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (93-unlock-idx-ambiguous.c:24:3-24:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization lock --enable ana.sv-comp.functions 93-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (93-unlock-idx-ambiguous.c:14:3-14:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (93-unlock-idx-ambiguous.c:24:3-24:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization write --enable ana.sv-comp.functions 93-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (93-unlock-idx-ambiguous.c:14:3-14:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (93-unlock-idx-ambiguous.c:24:3-24:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization mine-nothread --enable ana.sv-comp.functions 93-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (93-unlock-idx-ambiguous.c:14:3-14:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (93-unlock-idx-ambiguous.c:24:3-24:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// PARAM: --set ana.base.privatization protection --enable ana.sv-comp.functions | ||
#include <pthread.h> | ||
#include <goblint.h> | ||
|
||
int g; | ||
pthread_mutex_t m[2] = {PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}; | ||
|
||
void *t_fun(void *arg) { | ||
pthread_mutex_lock(&m[0]); | ||
g++; | ||
pthread_mutex_t *r; // rand | ||
pthread_mutex_unlock(r); | ||
// could have unlocked m[0], so should have published g there | ||
return NULL; | ||
} | ||
|
||
int main() { | ||
pthread_t id; | ||
pthread_create(&id, NULL, t_fun, NULL); | ||
|
||
pthread_mutex_lock(&m[0]); | ||
__goblint_check(g == 0); // UNKNOWN! | ||
pthread_mutex_unlock(&m[0]); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
$ goblint --set ana.base.privatization protection --enable ana.sv-comp.functions 94-unlock-unknown.c | ||
[Warning][Unknown] unlocking unknown mutex which may not be held (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Unknown] unlocking NULL mutex (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (94-unlock-unknown.c:22:3-22:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 11 | ||
dead: 0 | ||
total lines: 11 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization mutex-meet --enable ana.sv-comp.functions 94-unlock-unknown.c | ||
[Warning][Unknown] unlocking unknown mutex which may not be held (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Unknown] unlocking NULL mutex (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (94-unlock-unknown.c:22:3-22:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 11 | ||
dead: 0 | ||
total lines: 11 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization lock --enable ana.sv-comp.functions 94-unlock-unknown.c | ||
[Warning][Unknown] unlocking unknown mutex which may not be held (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Unknown] unlocking NULL mutex (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (94-unlock-unknown.c:22:3-22:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 11 | ||
dead: 0 | ||
total lines: 11 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization write --enable ana.sv-comp.functions 94-unlock-unknown.c | ||
[Warning][Unknown] unlocking unknown mutex which may not be held (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Unknown] unlocking NULL mutex (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (94-unlock-unknown.c:22:3-22:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 11 | ||
dead: 0 | ||
total lines: 11 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.base.privatization mine-nothread --enable ana.sv-comp.functions 94-unlock-unknown.c | ||
[Warning][Unknown] unlocking unknown mutex which may not be held (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Unknown] unlocking NULL mutex (94-unlock-unknown.c:12:3-12:26) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (94-unlock-unknown.c:22:3-22:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 11 | ||
dead: 0 | ||
total lines: 11 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(cram | ||
(deps (glob_files *.c))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// PARAM: --set ana.activated[+] apron --set ana.relation.privatization mutex-meet --enable ana.sv-comp.functions --set ana.path_sens[+] threadflag | ||
// TODO: why nonterm without threadflag path-sens? | ||
#include <pthread.h> | ||
#include <goblint.h> | ||
extern _Bool __VERIFIER_nondet_bool(); | ||
|
||
int g; | ||
pthread_mutex_t m[2] = {PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}; | ||
|
||
void *t_fun(void *arg) { | ||
pthread_mutex_lock(&m[0]); | ||
pthread_mutex_lock(&m[1]); // so we're unlocking a mutex we definitely hold | ||
g++; | ||
int r = __VERIFIER_nondet_bool(); | ||
pthread_mutex_unlock(&m[r]); // TODO NOWARN (definitely held either way) | ||
// could have unlocked m[0], so should have published g there | ||
return NULL; | ||
} | ||
|
||
int main() { | ||
pthread_t id; | ||
pthread_create(&id, NULL, t_fun, NULL); | ||
|
||
pthread_mutex_lock(&m[0]); | ||
__goblint_check(g == 0); // UNKNOWN! | ||
pthread_mutex_unlock(&m[0]); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
$ goblint --set ana.activated[+] apron --set ana.relation.privatization mutex-meet --enable ana.sv-comp.functions --set ana.path_sens[+] threadflag 87-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (87-unlock-idx-ambiguous.c:15:3-15:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (87-unlock-idx-ambiguous.c:25:3-25:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.activated[+] apron --set ana.relation.privatization mutex-meet-tid --enable ana.sv-comp.functions --set ana.path_sens[+] threadflag 87-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (87-unlock-idx-ambiguous.c:15:3-15:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (87-unlock-idx-ambiguous.c:25:3-25:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
||
$ goblint --set ana.activated[+] apron --set ana.relation.privatization mutex-meet-tid-cluster12 --enable ana.sv-comp.functions --set ana.path_sens[+] threadflag 87-unlock-idx-ambiguous.c | ||
[Warning][Unknown] unlocking mutex (m[def_exc:Unknown int([0,1])]) which may not be held (87-unlock-idx-ambiguous.c:15:3-15:30) | ||
[Warning][Assert] Assertion "g == 0" is unknown. (87-unlock-idx-ambiguous.c:25:3-25:26) | ||
[Info][Deadcode] Logical lines of code (LLoC) summary: | ||
live: 14 | ||
dead: 0 | ||
total lines: 14 | ||
[Info][Race] Memory locations race summary: | ||
safe: 1 | ||
vulnerable: 0 | ||
unsafe: 0 | ||
total memory locations: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// PARAM: --set ana.activated[+] apron --set ana.relation.privatization mutex-meet --enable ana.sv-comp.functions | ||
#include <pthread.h> | ||
#include <goblint.h> | ||
|
||
int g; | ||
pthread_mutex_t m[2] = {PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}; | ||
|
||
void *t_fun(void *arg) { | ||
pthread_mutex_lock(&m[0]); | ||
g++; | ||
pthread_mutex_t *r; // rand | ||
pthread_mutex_unlock(r); | ||
// could have unlocked m[0], so should have published g there | ||
return NULL; | ||
} | ||
|
||
int main() { | ||
pthread_t id; | ||
pthread_create(&id, NULL, t_fun, NULL); | ||
|
||
pthread_mutex_lock(&m[0]); | ||
__goblint_check(g == 0); // UNKNOWN! | ||
pthread_mutex_unlock(&m[0]); | ||
return 0; | ||
} |
Oops, something went wrong.