This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Add interceptors for dispatch_apply
ClosedPublic

Authored by kubamracek on Apr 2 2016, 2:42 AM.

Details

Summary

Adding an interceptor with two more release+acquire pairs to avoid false positives with dispatch_apply.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek updated this revision to Diff 52459.Apr 2 2016, 2:42 AM
kubamracek retitled this revision from to [tsan] Add interceptors for dispatch_apply.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, kcc, glider, samsonov.
dvyukov added inline comments.Apr 2 2016, 6:41 AM
lib/tsan/rtl/tsan_libdispatch_mac.cc
300 ↗(On Diff #52459)

Why do we need this around REAL(dispatch_apply)?

test/tsan/Darwin/gcd-apply-race.mm
13 ↗(On Diff #52459)

Please use the barrier functionality from test.h. The sleep will make the test run for at least a second.
It should be enough to do:

int main(...) {

  barrier_init(&barrier, 2);
  ...
  dispatch_apply(2, q, ^(size_t i) {
      global = i;
      barrier_wait(&barrier);
  }
}
test/tsan/Darwin/gcd-apply.mm
12 ↗(On Diff #52459)

same here

24 ↗(On Diff #52459)

same here

kubamracek added inline comments.Apr 2 2016, 10:21 AM
lib/tsan/rtl/tsan_libdispatch_mac.cc
300 ↗(On Diff #52459)

dispatch_apply can use the current thread (if it's part of queue) and call the callback on it.

kubamracek updated this revision to Diff 52467.Apr 2 2016, 10:23 AM

Updating patch.

dvyukov accepted this revision.Apr 2 2016, 11:03 PM
dvyukov edited edge metadata.
This revision is now accepted and ready to land.Apr 2 2016, 11:03 PM
This revision was automatically updated to reflect the committed changes.