Skip to content

Commit

Permalink
Add test for unknown thread id
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliineh committed Oct 27, 2023
1 parent 192108b commit 1221860
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/regression/51-threadjoins/07-trivial-unknowntid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//PARAM: --set ana.activated[+] threadJoins
#include <pthread.h>

int g = 10;
int h = 10;
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
g++; // RACE!
return NULL;
}

void *t_benign(void *arg) {
h++; // NORACE
pthread_t id2;
pthread_create(&id2, NULL, t_fun, NULL);
foo(&id2);
pthread_join(id2, NULL);
return NULL;
}

int main(void) {
int t;

pthread_t id2;
pthread_create(&id2, NULL, t_benign, NULL);
pthread_join(id2, NULL);
// t_benign and t_fun should be in here

g++; // RACE!
h++; // NORACE

return 0;
}

0 comments on commit 1221860

Please sign in to comment.