[PATCH] D14283: [tsan] Allow memchr interceptor to be used before initialization on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 07:00:57 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: samsonov, kcc, glider, dvyukov.
kubabrecka added subscribers: llvm-commits, zaks.anna, ismailp, jasonk.

On OS X, `memchr` is called on a newly created thread even before `__tsan_thread_start_func` is invoked, which means that the ThreadState object for that thread will not yet be initialized.  Let's add `COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED` into the interceptor to simply call the original `memchr` in these cases.

http://reviews.llvm.org/D14283

Files:
  lib/sanitizer_common/sanitizer_common_interceptors.inc

Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -441,6 +441,8 @@
 
 #if SANITIZER_INTERCEPT_MEMCHR
 INTERCEPTOR(void*, memchr, const void *s, int c, SIZE_T n) {
+  if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+    return REAL(memchr)(s, c, n);
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, memchr, s, c, n);
   void *res = REAL(memchr)(s, c, n);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14283.39057.patch
Type: text/x-patch
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151103/4faf5b95/attachment.bin>


More information about the llvm-commits mailing list