This is an archive of the discontinued LLVM Phabricator instance.

tsan: fix test invisible barrier
ClosedPublic

Authored by dvyukov on Dec 7 2015, 5:45 AM.

Details

Summary

Another attempt at fixing tsan_invisible_barrier.
Current implementation causes:
https://llvm.org/bugs/show_bug.cgi?id=25643

There were several unsuccessful iterations for this functionality:

  1. Initially it was implemented in user code using REAL(pthread_barrier_wait). But pthread_barrier_wait is not supported on MacOS. Futexes are linux-specific for this matter.
  2. Then we switched to atomics+usleep(10). But usleep produced parasitic "as-if synchronized via sleep" messages in reports which failed some output tests.
  3. Then we switched to atomics+sched_yield. But this produced tons of tsan- visible events, which lead to "failed to restore stack trace" failures.

Move implementation into runtime and use internal_sched_yield in the wait loop.
This way tsan should see no events from the barrier, so not trace overflows and
no "as-if synchronized via sleep" messages.

Diff Detail

Event Timeline

dvyukov updated this revision to Diff 42062.Dec 7 2015, 5:45 AM
dvyukov retitled this revision from to tsan: fix test invisible barrier.
dvyukov updated this object.
dvyukov added reviewers: kcc, eugenis.
dvyukov added subscribers: kubamracek, llvm-commits, krasin.
dvyukov updated this revision to Diff 42072.Dec 7 2015, 8:33 AM
samsonov added inline comments.
lib/tsan/rtl/tsan_interceptors.cc
2701

If these are only used in tests, can we name this __tsan_testonly_invisible_barrier_init?

2719

This doesn't match commit message (SleepForMillis).

test/tsan/load_shared_lib.cc
6

Why do you need this? I thought all __tsan symbols should be properly exported from executable...

dvyukov updated this revision to Diff 42185.Dec 8 2015, 8:55 AM
dvyukov updated this object.

addressed comments

dvyukov marked 2 inline comments as done.Dec 8 2015, 8:57 AM

PTAL

test/tsan/load_shared_lib.cc
6

There is an explicit list of symbols that we export. It is finer-grained than __tsan*.

samsonov accepted this revision.Dec 8 2015, 9:54 AM
samsonov added a reviewer: samsonov.

LGTM

This revision is now accepted and ready to land.Dec 8 2015, 9:54 AM

committed in 255030