[compiler-rt] d71775c - [asan] Run background thread for asan only on THUMB

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 9 10:43:33 PST 2021


Author: Vitaly Buka
Date: 2021-12-09T10:43:06-08:00
New Revision: d71775cd2ab171b377e32339276f513fd896b585

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

LOG: [asan] Run background thread for asan only on THUMB

As in D114934, or lsan crashes on the same bot.

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_rtl.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_platform.h
    compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
    compiler-rt/test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp
index 35b785a79e3ef..f0bbbf32e6a64 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -445,6 +445,9 @@ static void AsanInitInternal() {
   allocator_options.SetFrom(flags(), common_flags());
   InitializeAllocator(allocator_options);
 
+  if (SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL)
+    MaybeStartBackgroudThread();
+
   // On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited
   // should be set to 1 prior to initializing the threads.
   asan_inited = 1;

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
index fd54357adbe44..c5a5fb7371dd9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
@@ -189,8 +189,6 @@ bool AllocatorMayReturnNull() {
 void SetAllocatorMayReturnNull(bool may_return_null) {
   atomic_store(&allocator_may_return_null, may_return_null,
                memory_order_relaxed);
-  if (SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL)
-    MaybeStartBackgroudThread();
 }
 
 void PrintHintAllocatorCannotReturnNull() {

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
index 50564e62645de..a703db48d4c39 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
@@ -108,6 +108,8 @@ static struct BackgroudThreadStarted {
 } background_thread_strarter UNUSED;
 #    pragma clang diagnostic pop
 #  endif
+#else
+void MaybeStartBackgroudThread() {}
 #endif
 
 void WriteToSyslog(const char *msg) {

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index 6fc02e178b143..7c64bec7fd818 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -395,6 +395,9 @@
 #if defined(__thumb__) && defined(__linux__)
 // Workaround for
 // https://lab.llvm.org/buildbot/#/builders/clang-thumbv7-full-2stage
+// or
+// https://lab.llvm.org/staging/#/builders/clang-thumbv7-full-2stage
+// It fails *rss_limit_mb_test* without meaningful errors.
 #  define SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL 1
 #else
 #  define SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL 0

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
index 1b17a314f837a..5c239f2055e45 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
@@ -13,6 +13,9 @@
 // Ubsan does not intercept pthread_create.
 // XFAIL: ubsan
 
+// THUMB starts background thead only for Asan.
+// XFAIL: thumb && !asan
+
 // https://github.com/google/sanitizers/issues/981
 // UNSUPPORTED: android-26
 

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cpp b/compiler-rt/test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cpp
index 64e80bee3a134..4df5ba24d3c61 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cpp
@@ -14,6 +14,9 @@
 // XFAIL: ubsan
 // UNSUPPORTED: freebsd, solaris, darwin
 
+// THUMB starts background thead only for Asan.
+// XFAIL: thumb && !asan
+
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>


        


More information about the llvm-commits mailing list