[llvm-branch-commits] [compiler-rt] ed09029 - Fix LazyInitialization in tsan

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 24 17:57:08 PDT 2022


Author: zijunzhao
Date: 2022-10-25T00:55:41Z
New Revision: ed090295c51729bb41ef7acd5888ce2d9d1bd537

URL: https://github.com/llvm/llvm-project/commit/ed090295c51729bb41ef7acd5888ce2d9d1bd537
DIFF: https://github.com/llvm/llvm-project/commit/ed090295c51729bb41ef7acd5888ce2d9d1bd537.diff

LOG: Fix LazyInitialization in tsan

In Android, further initialization is always necessary whether preinit_array can be used.
LazyInitialize is needed regardless of .preinit_array support on platforms where runtime is loaded as dynamic library, e.g. Android.

Reviewed By: dvyukov, vitalybuka

Differential Revision: https://reviews.llvm.org/D135925

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_rtl.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 90164c893ee16..f0918d86d4ec3 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -678,8 +678,8 @@ ALWAYS_INLINE
 void LazyInitialize(ThreadState *thr) {
   // If we can use .preinit_array, assume that __tsan_init
   // called from .preinit_array initializes runtime before
-  // any instrumented code.
-#if !SANITIZER_CAN_USE_PREINIT_ARRAY
+  // any instrumented code except ANDROID.
+#if (!SANITIZER_CAN_USE_PREINIT_ARRAY || defined(__ANDROID__))
   if (UNLIKELY(!is_initialized))
     Initialize(thr);
 #endif


        


More information about the llvm-branch-commits mailing list