Skip to content

Commit

Permalink
Add test case with pthread_exit called in main, remove threadid analy…
Browse files Browse the repository at this point in the history
…sis from params as it is not needed.
  • Loading branch information
jerhard committed Nov 21, 2023
1 parent 45ec8a6 commit 56c4d62
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread --set ana.activated[+] threadid
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread
#include <stdlib.h>
#include <pthread.h>

Expand Down Expand Up @@ -26,7 +26,7 @@ int main(int argc, char const *argv[]) {

pthread_t t2;
pthread_create(&t2, NULL, f2, NULL);

free(g);

pthread_join(t1, NULL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread --set ana.activated[+] threadid
#include <stdlib.h>
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread
#include <pthread.h>

int *g;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.base.privatization mutex-meet-tid --set ana.path_sens[+] threadflag --set ana.activated[+] thread --set ana.activated[+] threadid
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.base.privatization mutex-meet-tid --set ana.path_sens[+] threadflag --set ana.activated[+] thread
#include <stdlib.h>
#include <pthread.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread --set ana.activated[+] threadid
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread
#include <stdlib.h>
#include <pthread.h>

Expand Down
23 changes: 23 additions & 0 deletions tests/regression/76-memleak/16-no-mem-leak-thread-exit-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread
#include <stdlib.h>
#include <pthread.h>

int *m1;

void *f1(void *arg) {
m1 = malloc(sizeof(int));
while (1);
}

int main(int argc, char const *argv[]) {
pthread_t t1;
pthread_create(&t1, NULL, f1, NULL);

pthread_exit(NULL);

pthread_join(t1, NULL);

// A pthread_join called in main will wait for other threads to finish
// Therefore, no memory leak here
return 0; // NOWARN
}

0 comments on commit 56c4d62

Please sign in to comment.