Merge "Disable malloc debug when asan enabled." am: 497d7169d4
am: 39677eae59

Change-Id: I6d0edb1d0fad919657f1cb8e58b0d20136b6dc77
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 53fcead..c030d54 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -252,12 +252,19 @@
   return g_debug->GetPointer(header);
 }
 
+extern "C" void __asan_init() __attribute__((weak));
+
 bool debug_initialize(const MallocDispatch* malloc_dispatch, bool* zygote_child,
                       const char* options) {
   if (zygote_child == nullptr || options == nullptr) {
     return false;
   }
 
+  if (__asan_init != 0) {
+    error_log("malloc debug cannot be enabled alongside ASAN");
+    return false;
+  }
+
   InitAtfork();
 
   g_zygote_child = zygote_child;