OSDN Git Service

GD-Facade: Enable ASAN but disable container overflow check
authorJack He <siyuanh@google.com>
Sat, 12 Dec 2020 00:01:58 +0000 (16:01 -0800)
committerJack He <siyuanh@google.com>
Mon, 14 Dec 2020 05:03:20 +0000 (21:03 -0800)
* AddressSanitizerContainerOverflow has false positives because not
  all dependencies are compiled with ASAN according to:
  https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow
* Hence we need to disable container overflow check. We do this at
  compile time per instructiosn at:
  https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags

Bug: 175033589
Test: gd/cert/run
Tag: #gd-refactor
Change-Id: I80a0fbcef022101b57d1c68919add6acf6aa81e4

gd/Android.bp
gd/facade/facade_main.cc
vendor_libs/test_vendor_lib/desktop/root_canal_main.cc

index f35ab30..2e9d59a 100644 (file)
@@ -251,6 +251,10 @@ cc_binary {
             ],
         },
     },
+    sanitize: {
+        address: true,
+        cfi: true,
+    }
 }
 
 cc_test {
index 5ea2f46..0bba727 100644 (file)
@@ -46,6 +46,10 @@ using ::bluetooth::StackManager;
 using ::bluetooth::hal::HciHalHostRootcanalConfig;
 using ::bluetooth::os::Thread;
 
+extern "C" const char* __asan_default_options() {
+  return "detect_container_overflow=0";
+}
+
 namespace {
 ::bluetooth::facade::GrpcRootServer grpc_root_server;
 
index ff35b09..f67f3ba 100644 (file)
@@ -31,6 +31,10 @@ constexpr uint16_t kTestPort = 6401;
 constexpr uint16_t kHciServerPort = 6402;
 constexpr uint16_t kLinkServerPort = 6403;
 
+extern "C" const char* __asan_default_options() {
+  return "detect_container_overflow=0";
+}
+
 bool crash_callback(const void* crash_context, size_t crash_context_size,
                     __attribute__((unused)) void* context) {
   pid_t tid = BACKTRACE_CURRENT_THREAD;