[PATCH] D14379: [tsan] Fix pthread_once interceptor for OS X

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 06:01:28 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL252160: [tsan] Fix pthread_once interceptor for OS X (authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D14379?vs=39337&id=39355#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14379

Files:
  compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc

Index: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
@@ -1293,7 +1293,11 @@
   SCOPED_INTERCEPTOR_RAW(pthread_once, o, f);
   if (o == 0 || f == 0)
     return EINVAL;
-  atomic_uint32_t *a = static_cast<atomic_uint32_t*>(o);
+  atomic_uint32_t *a;
+  if (!SANITIZER_MAC)
+    a = static_cast<atomic_uint32_t*>(o);
+  else  // On OS X, pthread_once_t has a header with a long-sized signature.
+    a = static_cast<atomic_uint32_t*>((void *)((char *)o + sizeof(long)));
   u32 v = atomic_load(a, memory_order_acquire);
   if (v == 0 && atomic_compare_exchange_strong(a, &v, 1,
                                                memory_order_relaxed)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14379.39355.patch
Type: text/x-patch
Size: 835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151105/488a212b/attachment.bin>


More information about the llvm-commits mailing list