-
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.
Add mine-W-noinit test for resetting W in threadenter
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// PARAM: --set ana.base.privatization mine-W-noinit --enable ana.int.enums | ||
#include <pthread.h> | ||
#include <goblint.h> | ||
|
||
int g; | ||
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER; | ||
|
||
void *t_fun(void *arg) { | ||
return NULL; | ||
} | ||
|
||
void *t_fun2(void *arg) { | ||
pthread_mutex_lock(&A); | ||
pthread_mutex_unlock(&A); // spuriously publishes g = 8 | ||
return NULL; | ||
} | ||
|
||
int main() { | ||
pthread_t id, id2; | ||
pthread_create(&id, NULL, t_fun, NULL); // enter multithreaded | ||
|
||
pthread_mutex_lock(&A); | ||
g = 8; | ||
pthread_create(&id2, NULL, t_fun2, NULL); // passes g = 8 and W: A -> {g} to t_fun2 | ||
g = 0; | ||
pthread_mutex_unlock(&A); | ||
|
||
pthread_mutex_lock(&A); | ||
__goblint_check(g == 0); // TODO | ||
pthread_mutex_unlock(&A); | ||
return 0; | ||
} |