summaryrefslogtreecommitdiff
path: root/test/tsan
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2016-12-15 16:45:28 +0000
committerKuba Mracek <mracek@apple.com>2016-12-15 16:45:28 +0000
commit24f3d740ead904f40dbf61f63d58fa7abba991bb (patch)
tree185b5e0a1aece1c9f7bb5f517c7eb9843a7293df /test/tsan
parent771f7d7aa60c4ed9310637d6c444d08b2002d7ed (diff)
[tsan] Add interceptor for libcxx __shared_count::__release_shared()
We already have an interceptor for __shared_weak_count::__release_shared, this patch handles __shared_count::__release_shared in the same way. This should get rid of TSan false positives when using std::future. Differential Revision: https://reviews.llvm.org/D27797 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289831 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan')
-rw-r--r--test/tsan/Darwin/libcxx-future.mm30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/tsan/Darwin/libcxx-future.mm b/test/tsan/Darwin/libcxx-future.mm
new file mode 100644
index 000000000..f004d7b38
--- /dev/null
+++ b/test/tsan/Darwin/libcxx-future.mm
@@ -0,0 +1,30 @@
+// RUN: %clangxx_tsan %s -o %t
+// RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %run %t 2>&1 | FileCheck %s
+
+#include <iostream>
+#include <future>
+#include <vector>
+
+int main(int argc, const char *argv[]) {
+ fprintf(stderr, "Hello world.\n");
+
+ auto my_task = [] { return 42; };
+
+ std::vector<std::thread> threads;
+
+ for (int i = 0; i < 1000; i++) {
+ std::packaged_task<int(void)> task(my_task);
+ std::future<int> future = task.get_future();
+ threads.push_back(std::thread(std::move(task)));
+ }
+
+ for (auto &t : threads) {
+ t.join();
+ }
+
+ fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK: Done.