-
Notifications
You must be signed in to change notification settings - Fork 76
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 #1640 from goblint/mine-W-noinit-threadenter
Fix `mine-W-noinit` not resetting W in `threadenter`
- Loading branch information
Showing
2 changed files
with
35 additions
and
3 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
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); // used to spuriously publish 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); // used to pass g = 8 and W: A -> {g} to t_fun2 | ||
g = 0; | ||
pthread_mutex_unlock(&A); | ||
|
||
pthread_mutex_lock(&A); | ||
__goblint_check(g == 0); | ||
pthread_mutex_unlock(&A); | ||
return 0; | ||
} |