[compiler-rt] 1f8031c - [android] Fix some tests for AOSP-master devices.

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 5 12:54:40 PST 2021


Author: Mitch Phillips
Date: 2021-01-05T12:54:09-08:00
New Revision: 1f8031cd74887025a5de1e7129718186369db769

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

LOG: [android] Fix some tests for AOSP-master devices.

Some tests are broken at API level 30 on AOSP-master devices. When we
change the buildbuit to API level 30, the following tests get enabled.
They're currently broken due to various issues, and so fix up those
issues.

Reviewed By: oontvoo, eugenis

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

Added: 
    

Modified: 
    compiler-rt/test/cfi/cross-dso/target_out_of_bounds.cpp
    compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
    compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/cfi/cross-dso/target_out_of_bounds.cpp b/compiler-rt/test/cfi/cross-dso/target_out_of_bounds.cpp
index 6353f030a6ac..80b736e2c91c 100644
--- a/compiler-rt/test/cfi/cross-dso/target_out_of_bounds.cpp
+++ b/compiler-rt/test/cfi/cross-dso/target_out_of_bounds.cpp
@@ -10,6 +10,12 @@
 
 // REQUIRES: cxxabi
 
+// These checks are unsupported on newer versions of Android due to the
+// following patch that makes it harder to defeat ASLR by not mapping unused
+// shadow regions:
+// https://android-review.googlesource.com/c/platform/bionic/+/1333960
+// UNSUPPORTED: android
+
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>

diff  --git a/compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp b/compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
index be1cdc943c6a..63a7c87f66da 100644
--- a/compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
+++ b/compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
@@ -23,6 +23,11 @@
 int main(int argc, char *argv[]) {
   std::string path = std::string(argv[0]) + "-so.so";
 
+  // Clear any previous errors. On Android, the dynamic loader can have some
+  // left over dlerror() messages due to a missing symbol resolution for a
+  // deprecated malloc function.
+  dlerror();
+
   void *handle = dlopen(path.c_str(), RTLD_LAZY);
   assert(handle != 0);
   typedef void **(* store_t)(void *p);
@@ -31,10 +36,10 @@ int main(int argc, char *argv[]) {
   // Sometimes dlerror() occurs when we broke the interceptors.
   // Add the message here to make the error more obvious.
   const char *dlerror_msg = dlerror();
-  assert(dlerror_msg == nullptr);
   if (dlerror_msg != nullptr) {
     fprintf(stderr, "DLERROR: %s\n", dlerror_msg);
     fflush(stderr);
+    abort();
   }
   void *p = malloc(1337);
   // If we don't  know about dynamic TLS, we will return a false leak above.

diff  --git a/compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp b/compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
index 72aee5f56fd9..fa644c6cb451 100644
--- a/compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
+++ b/compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
@@ -1,6 +1,15 @@
 // Test that out-of-scope local variables are ignored by LSan.
 // RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=1"
-// RUN: %clangxx_lsan %s -o %t
+
+// LSan-in-ASan fails at -O0 on aarch64, because the stack use-after-return
+// instrumentation stashes the argument to `PutPointerOnStaleStack` on the stack
+// in order to conditionally call __asan_stack_malloc. This subverts our
+// expectations for this test, where we assume the pointer is never stashed
+// except at the bottom of the dead frame. Building at -O1 or greater solves
+// this problem, because the compiler is smart enough to stash the argument in a
+// callee-saved register for rematerialization instead.
+// RUN: %clangxx_lsan -O1 %s -o %t
+
 // RUN: %env_lsan_opts=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
 // RUN: %env_lsan_opts=$LSAN_BASE":exitcode=0" %run %t 2>&1 | FileCheck --check-prefix=CHECK-sanity %s
 //


        


More information about the llvm-commits mailing list