[PATCH] D14811: [tsan] Handle dispatch_once on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 02:32:13 PST 2015


kubabrecka added inline comments.

================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:65
@@ +64,3 @@
+  SCOPED_TSAN_INTERCEPTOR(dispatch_once_f, predicate, context, function);
+  WRAP(dispatch_once)(predicate, ^{ function(context); });
+}
----------------
dvyukov wrote:
> For my education: how do these blocks work? Are they allocated with malloc, and then atomically reference-counted?
Initially, they are created on the stack (a descriptor containing a function pointer and data).  In function calls, we just pass a pointer to this stack variable.  Only when we need to store a block reference to somewhere else (global variable, heap location), we transform it into a heap object (malloc'd).  In this case (dispatch_once_f), we never do that, because we only pass it around as arguments and invoke it.

Would there be any issues if it was always malloc'd?


http://reviews.llvm.org/D14811





More information about the llvm-commits mailing list