Skip to content

Commit 690ee20

Browse files
committed
Add test where address containing unknown should escape known
1 parent e41a033 commit 690ee20

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <pthread.h>
2+
#include <assert.h>
3+
4+
int *p;
5+
6+
void *t_fun(void *arg) {
7+
if (arg != NULL) {
8+
*((int*)arg) = 42;
9+
}
10+
return NULL;
11+
}
12+
13+
int main() {
14+
pthread_t id, id2;
15+
int *r; // unknown
16+
int i = 5;
17+
18+
pthread_create(&id, NULL, t_fun, NULL); // enter multithreaded
19+
20+
p = r;
21+
p = &i;
22+
23+
pthread_create(&id2, NULL, t_fun, p); // i should escape, even if p contains unknown
24+
25+
assert(i == 5); // UNKNOWN!
26+
27+
return 0;
28+
}

0 commit comments

Comments
 (0)