-
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.
Merge remote-tracking branch 'mrstanb/improve-multi-threaded-valid-me…
…mcleanup' into svcomp24-dev
- Loading branch information
Showing
15 changed files
with
440 additions
and
23 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
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
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
36 changes: 36 additions & 0 deletions
36
tests/regression/76-memleak/20-invalid-memcleanup-multi-threaded.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,36 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
|
||
int *g; | ||
int *m1; | ||
|
||
void *f1(void *arg) { | ||
m1 = malloc(sizeof(int)); | ||
// Thread t1 leaks m1 here | ||
pthread_exit(NULL); //WARN | ||
} | ||
|
||
void *f2(void *arg) { | ||
int *m2; | ||
m2 = malloc(sizeof(int)); | ||
free(m2); // No leak for thread t2, since it calls free before exiting | ||
pthread_exit(NULL); //NOWARN | ||
} | ||
|
||
int main(int argc, char const *argv[]) { | ||
g = malloc(sizeof(int)); | ||
pthread_t t1; | ||
pthread_create(&t1, NULL, f1, NULL); | ||
|
||
pthread_t t2; | ||
pthread_create(&t2, NULL, f2, NULL); | ||
|
||
free(g); | ||
|
||
pthread_join(t1, NULL); | ||
pthread_join(t2, NULL); | ||
|
||
// main thread is not leaking anything | ||
return 0; //NOWARN | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/regression/76-memleak/21-invalid-memcleanup-multi-threaded-abort.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,35 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --set ana.activated[+] thread | ||
#include <pthread.h> | ||
|
||
int *g; | ||
int *m1; | ||
|
||
void *f1(void *arg) { | ||
m1 = malloc(sizeof(int)); | ||
// Thread t1 leaks m1 here | ||
exit(2); //WARN | ||
} | ||
|
||
void *f2(void *arg) { | ||
int *m2; | ||
m2 = malloc(sizeof(int)); | ||
free(m2); // No leak for thread t2, since it calls free before exiting | ||
pthread_exit(NULL); //NOWARN | ||
} | ||
|
||
int main(int argc, char const *argv[]) { | ||
g = malloc(sizeof(int)); | ||
pthread_t t1; | ||
pthread_create(&t1, NULL, f1, NULL); | ||
|
||
pthread_t t2; | ||
pthread_create(&t2, NULL, f2, NULL); | ||
|
||
free(g); | ||
|
||
pthread_join(t1, NULL); | ||
pthread_join(t2, NULL); | ||
|
||
// main thread is not leaking anything | ||
return 0; //NOWARN | ||
} |
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,25 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
|
||
int *g; | ||
int *m1; | ||
int *m2; | ||
|
||
void *f1(void *arg) { | ||
int top; | ||
|
||
// Thread t1 leaks m0 here | ||
exit(2); //WARN | ||
} | ||
|
||
int main(int argc, char const *argv[]) { | ||
pthread_t t1; | ||
pthread_create(&t1, NULL, f1, NULL); | ||
|
||
int* m0 = malloc(sizeof(int)); | ||
free(m0); | ||
|
||
// main thread is not leaking anything | ||
return 0; | ||
} |
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,34 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
|
||
int *g; | ||
int *m1; | ||
int *m2; | ||
|
||
void *f2(void *arg) { | ||
// Thread t2 leaks m0 and t1_ptr here | ||
quick_exit(2); //WARN | ||
} | ||
|
||
void *f1(void *arg) { | ||
pthread_t t2; | ||
pthread_create(&t2, NULL, f2, NULL); | ||
|
||
int *t1_ptr = malloc(sizeof(int)); | ||
|
||
pthread_join(t2, NULL); | ||
// t1_ptr is leaked, since t2 calls quick_exit() potentially before this program point | ||
free(t1_ptr); | ||
} | ||
|
||
int main(int argc, char const *argv[]) { | ||
pthread_t t1; | ||
pthread_create(&t1, NULL, f1, NULL); | ||
|
||
int* m0 = malloc(sizeof(int)); | ||
free(m0); | ||
|
||
// main thread is not leaking anything | ||
return 0; | ||
} |
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,34 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --disable warn.assert | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <assert.h> | ||
|
||
int *g; | ||
int *m1; | ||
int *m2; | ||
|
||
void *f2(void *arg) { | ||
// Thread t2 leaks m0 and t1_ptr here | ||
assert(0); //WARN | ||
} | ||
|
||
void *f1(void *arg) { | ||
pthread_t t2; | ||
pthread_create(&t2, NULL, f2, NULL); | ||
|
||
int *t1_ptr = malloc(sizeof(int)); | ||
assert(1); //NOWARN | ||
pthread_join(t2, NULL); | ||
free(t1_ptr); | ||
} | ||
|
||
int main(int argc, char const *argv[]) { | ||
pthread_t t1; | ||
pthread_create(&t1, NULL, f1, NULL); | ||
|
||
int* m0 = malloc(sizeof(int)); | ||
free(m0); | ||
|
||
// main thread is not leaking anything | ||
return 0; | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/regression/76-memleak/25-assert-unknown-multi-threaded.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,20 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak --disable warn.assert | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <assert.h> | ||
|
||
void *f1(void *arg) { | ||
int top; | ||
assert(top); //WARN | ||
} | ||
|
||
int main(int argc, char const *argv[]) { | ||
pthread_t t1; | ||
pthread_create(&t1, NULL, f1, NULL); | ||
|
||
int* m0 = malloc(sizeof(int)); | ||
free(m0); | ||
|
||
// main thread is not leaking anything | ||
return 0; | ||
} |
Oops, something went wrong.