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
12 // Reports use-of-uninitialized-value, not analyzed
15 // This is known to be broken with glibc-2.27+
16 // https://bugs.llvm.org/show_bug.cgi?id=37804
28 typedef long *(* get_t)();
30 void *Thread1(void *unused) {
34 fprintf(stderr, "bar\n");
36 fprintf(stderr, "stack: %p dtls: %p\n", &x, x);
40 void *Thread2(void *unused) {
42 fprintf(stderr, "stack: %p dtls: %p\n", &x, x);
44 fprintf(stderr, "foo\n"); // False negative here.
48 int main(int argc, char *argv[]) {
50 snprintf(path, sizeof(path), "%s-so.so", argv[0]);
53 void *handle = dlopen(path, RTLD_LAZY);
54 if (!handle) fprintf(stderr, "%s\n", dlerror());
56 GetTls = (get_t)dlsym(handle, "GetTls");
57 assert(dlerror() == 0);
60 pthread_create(&t, 0, Thread1, 0);
62 pthread_create(&t, 0, Thread2, 0);
67 __thread long huge_thread_local_array[1 << 17];
69 return &huge_thread_local_array[0];