diff --git a/tests/regression/76-memleak/08-invalid-memcleanup-multi-threaded.c b/tests/regression/76-memleak/08-invalid-memcleanup-multi-threaded.c index 65e6e4e766..89dc7a3416 100644 --- a/tests/regression/76-memleak/08-invalid-memcleanup-multi-threaded.c +++ b/tests/regression/76-memleak/08-invalid-memcleanup-multi-threaded.c @@ -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 #include @@ -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); diff --git a/tests/regression/76-memleak/09-invalid-memcleanup-multi-threaded-abort.c b/tests/regression/76-memleak/09-invalid-memcleanup-multi-threaded-abort.c index b991433f4d..eaba1e91b5 100644 --- a/tests/regression/76-memleak/09-invalid-memcleanup-multi-threaded-abort.c +++ b/tests/regression/76-memleak/09-invalid-memcleanup-multi-threaded-abort.c @@ -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 +//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread #include int *g; diff --git a/tests/regression/76-memleak/14-invalid-memcleanup-multi-threaded-betterpiv.c b/tests/regression/76-memleak/14-invalid-memcleanup-multi-threaded-betterpiv.c index 7ad9194d6e..9f636ab587 100644 --- a/tests/regression/76-memleak/14-invalid-memcleanup-multi-threaded-betterpiv.c +++ b/tests/regression/76-memleak/14-invalid-memcleanup-multi-threaded-betterpiv.c @@ -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 #include diff --git a/tests/regression/76-memleak/15-mem-leak-not-joined-thread.c b/tests/regression/76-memleak/15-mem-leak-not-joined-thread.c index c60809a9f4..21c1992fc3 100644 --- a/tests/regression/76-memleak/15-mem-leak-not-joined-thread.c +++ b/tests/regression/76-memleak/15-mem-leak-not-joined-thread.c @@ -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 #include diff --git a/tests/regression/76-memleak/16-no-mem-leak-thread-exit-main.c b/tests/regression/76-memleak/16-no-mem-leak-thread-exit-main.c new file mode 100644 index 0000000000..5fb89113d2 --- /dev/null +++ b/tests/regression/76-memleak/16-no-mem-leak-thread-exit-main.c @@ -0,0 +1,23 @@ +//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread +#include +#include + +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 +} \ No newline at end of file