1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t
3 // Make sure TSan doesn't deadlock on a file stream lock at program shutdown.
4 // See https://code.google.com/p/thread-sanitizer/issues/detail?id=47
9 void *thread(void *unused
) {
14 // Forge a non-standard stream to make sure it's not closed.
15 FILE *stream
= fdopen(fd
[0], "r");
17 volatile int res
= getline(&line
, &size
, stream
);
26 pthread_attr_init(&a
);
27 pthread_attr_setdetachstate(&a
, PTHREAD_CREATE_DETACHED
);
28 pthread_create(&t
, &a
, thread
, NULL
);
29 pthread_attr_destroy(&a
);
30 fprintf(stderr
, "DONE\n");
32 // ThreadSanitizer used to hang here because of a deadlock on a file stream.