[PATCH] D18722: [tsan] Add interceptors for dispatch_apply

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 2 06:41:51 PDT 2016


dvyukov added inline comments.

================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:300
@@ +299,3 @@
+  };
+  SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START();
+  REAL(dispatch_apply)(iterations, queue, new_block);
----------------
Why do we need this around REAL(dispatch_apply)?

================
Comment at: test/tsan/Darwin/gcd-apply-race.mm:13
@@ +12,3 @@
+    global = i;
+    sleep(1);  // force multiple threads
+  });
----------------
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);
    }
  }

================
Comment at: test/tsan/Darwin/gcd-apply.mm:12
@@ +11,3 @@
+  array[i] = n + i;
+  usleep(1000);  // force multiple threads
+}
----------------
same here

================
Comment at: test/tsan/Darwin/gcd-apply.mm:24
@@ +23,3 @@
+    array[i] = n + i;
+    usleep(1000);  // force multiple threads
+  });
----------------
same here


http://reviews.llvm.org/D18722





More information about the llvm-commits mailing list