[asan] Run background thread for asan only on THUMB
authorVitaly Buka <vitalybuka@google.com>
Wed, 8 Dec 2021 20:28:12 +0000 (12:28 -0800)
committerVitaly Buka <vitalybuka@google.com>
Thu, 9 Dec 2021 18:43:06 +0000 (10:43 -0800)
As in D114934, or lsan crashes on the same bot.

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

index 35b785a..f0bbbf3 100644 (file)
@@ -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;
index fd54357..c5a5fb7 100644 (file)
@@ -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() {
index 50564e6..a703db4 100644 (file)
@@ -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) {
index 6fc02e1..7c64bec 100644 (file)
 #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
index 1b17a31..5c239f2 100644 (file)
@@ -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
 
index 64e80be..4df5ba2 100644 (file)
@@ -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>