On Sun, 4 Jan 2015 13:57:38, Mike Stump wrote: > > On Jan 4, 2015, at 1:48 PM, Bernd Edlinger <bernd.edlin...@hotmail.de> wrote: >> I would need a way to link the test case two helper functions, that are not >> compiled with -fsanitize=thread > > /* { dg-additional-sources “tsan-helper.c" } */ > > might be one step forward to do that. I don’t know off hand about the > options. I think you may be able to specify unique options per file. > >> I tried, it and it works 10.000 times without one failure. > > So, statistically knowing it works in practice is nice. However, the standard > is, does is work by design? I’ll let you comment on that. The sync approach I > designed to work in any case, no matter the complexity, by design. I’d assume > that you’ve engineered it to work by design.
IMO Yes, but Dmitry may know better. Tsan does not acquire a mutex _before_ it detects a race. And race conditions that happen exactly synchronous may be invisible. If we use some hidden mechanism to ensure that certain events happen in a certain sequence, that would make a big difference. It would work much better than sleep(), we only need sleep if we need to see the "as if synchronized via sleep" diagnostic. I see now, that our tsan tests are almost verbatim copies of the LLVM test suite. They _do_ have problems with the stability of positive tests, especially under stress, I see all positive tests are called by a "deflake" tool, that exercises the test 10 times, until it eventually succeeds. I see one other test (which we apparently do not have here), was changed recently from sleep(2) to sleep(4) [Tsan] Fix the atomic_race.cc test to pass on systems with high loads Differential Revision: http://reviews.llvm.org/D6478 --- compiler-rt/trunk/test/tsan/atomic_race.cc 2014/05/30 14:08:51 209898 +++ compiler-rt/trunk/test/tsan/atomic_race.cc 2014/12/02 15:04:39 223122 @@ -36,7 +36,7 @@ for (int i = 0; i < kTestCount; i++) { Test(i, &atomics[i], false); } - sleep(2); + sleep(4); for (int i = 0; i < kTestCount; i++) { fprintf(stderr, "Test %d reverse\n", i); Test(i, &atomics[kTestCount + i], false); Thanks Bernd.