1 /* RUN: %clang_msan -g %s -o %t
2 RUN: %clang_msan -g %s -DBUILD_SO -fPIC -o %t-so.so -shared
5 Regression test for a bug in msan/glibc integration,
6 see https://sourceware.org/bugzilla/show_bug.cgi?id=16291
7 and https://github.com/google/sanitizers/issues/547
9 XFAIL: target={{.*freebsd.*}}
10 UNSUPPORTED: target=powerpc{{.*}}
12 // Reports use-of-uninitialized-value, not analyzed
13 XFAIL: target={{.*netbsd.*}}
24 typedef long *(* get_t
)();
26 void *Thread1(void *unused
) {
30 fprintf(stderr
, "bar\n");
32 fprintf(stderr
, "stack: %p dtls: %p\n", &x
, x
);
36 void *Thread2(void *unused
) {
38 fprintf(stderr
, "stack: %p dtls: %p\n", &x
, x
);
40 fprintf(stderr
, "foo\n"); // False negative here.
44 int main(int argc
, char *argv
[]) {
46 snprintf(path
, sizeof(path
), "%s-so.so", argv
[0]);
49 void *handle
= dlopen(path
, RTLD_LAZY
);
50 if (!handle
) fprintf(stderr
, "%s\n", dlerror());
52 GetTls
= (get_t
)dlsym(handle
, "GetTls");
53 assert(dlerror() == 0);
56 pthread_create(&t
, 0, Thread1
, 0);
58 pthread_create(&t
, 0, Thread2
, 0);
63 __thread
long huge_thread_local_array
[1 << 17];
65 return &huge_thread_local_array
[0];