Hi! Back when I've added the EH support for tsan (aka TSAN_FUNC_EXIT), we didn't have the barrier_wait hack to make tsan threads reliable, so I didn't commit a testcase.
This one fails with that patch reverted and succeeds with the current trunk, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-03-18 Jakub Jelinek <ja...@redhat.com> PR sanitizer/64265 * g++.dg/tsan/pr64265.C: New test. --- gcc/testsuite/g++.dg/tsan/pr64265.C.jj 2015-03-18 17:47:28.871772124 +0100 +++ gcc/testsuite/g++.dg/tsan/pr64265.C 2015-03-18 18:00:39.342922371 +0100 @@ -0,0 +1,54 @@ +// PR sanitizer/64265 +// { dg-shouldfail "tsan" } +// { dg-additional-options "-fno-omit-frame-pointer -ldl" } + +#include <pthread.h> +#include "tsan_barrier.h" + +static pthread_barrier_t barrier; +int v; + +__attribute__((noinline, noclone)) int +foo (int x) +{ + if (x < 99) + throw x; + barrier_wait (&barrier); + v++; + return x; +} + +__attribute__((noinline, noclone)) void +bar (void) +{ + for (int i = 0; i < 100; i++) + try + { + foo (i); + } + catch (int) + { + } +} + +__attribute__((noinline, noclone)) void * +tf (void *) +{ + bar (); + return NULL; +} + +int +main () +{ + pthread_t th; + barrier_init (&barrier, 2); + if (pthread_create (&th, NULL, tf, NULL)) + return 0; + v++; + barrier_wait (&barrier); + pthread_join (th, NULL); + return 0; +} + +// { dg-output "WARNING: ThreadSanitizer: data race.*#2 _?(tf|_Z2tfPv)" } Jakub