-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix plain thread ID is_main unsoundness when ana.thread.include-node …
…is disabled
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
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
29 changes: 29 additions & 0 deletions
29
tests/regression/51-threadjoins/11-join-main-plain-no-node.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,29 @@ | ||
//PARAM: --set ana.activated[+] threadJoins --set ana.thread.domain plain --disable ana.thread.include-node | ||
#include <pthread.h> | ||
#include <stdio.h> | ||
|
||
pthread_t mainid; | ||
|
||
int g = 10; | ||
|
||
void *t_fun(void *arg) { | ||
int r = pthread_join(mainid, NULL); // TSan doesn't like this... | ||
printf("j: %d\n", r); | ||
g++; // RACE (imprecise by plain thread IDs) | ||
printf("t_fun: %d\n", g); | ||
return NULL; | ||
} | ||
|
||
|
||
int main(void) { | ||
mainid = pthread_self(); | ||
|
||
pthread_t id2; | ||
pthread_create(&id2, NULL, t_fun, NULL); | ||
|
||
g++; // RACE (imprecise by plain thread IDs not knowing if main is actual main or spawned by program) | ||
printf("main: %d\n", g); | ||
|
||
pthread_exit(NULL); // exit main thread but keep id2 alive, otherwise main returning kills id2 | ||
return 0; | ||
} |