-
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.
Add test case that checking that analysis distinguishes between threa…
…d returns and normal returns of a thread.
- 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.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
|
||
|
||
void *f2(void *arg) { | ||
int* m1 = malloc(sizeof(int)); | ||
free(m1); | ||
return NULL; | ||
} | ||
|
||
// We check here that the analysis can distinguish between thread returns and normal returns | ||
|
||
void startf2(pthread_t* t){ | ||
pthread_create(t, NULL, f2, NULL); | ||
return; //NOWARN | ||
} | ||
|
||
void *f1(void *arg) { | ||
pthread_t t2; | ||
startf2(&t2); | ||
pthread_join(t2, NULL); | ||
return NULL; // NOWARN | ||
} | ||
|
||
int main(int argc, char const *argv[]) { | ||
pthread_t t1; | ||
pthread_create(&t1, NULL, f1, NULL); | ||
pthread_join(t1, NULL); | ||
|
||
return 0; // NOWARN | ||
} |