[malloc dispatch] Install dispatch over the top of GWP-ASan.

When enabled, GWP-ASan sets the current dispatch table. Then, when a
shim layer (malloc_debug, malloc_hooks, heapprofd) comes along, they
should (by design) overwrite the current dispatch table.

Currently, these shim layers check to see whether malloc_limit is
installed by checking the current dispatch table against nullptr.
Because GWP-ASan owns the current dispatch table, the shim thinks that
malloc_limit is installed and falls back to only use the default
dispatch, thinking that malloc_limit will call them. This is not the
case, and they should take over the current dispatch pointer.

Bug: 135634846
Test: atest bionic

Change-Id: Ifb6f8864a15af9ac7f20d9364c40f73c5dd9d870
diff --git a/libc/bionic/malloc_limit.cpp b/libc/bionic/malloc_limit.cpp
index ebc33ab..1405a39 100644
--- a/libc/bionic/malloc_limit.cpp
+++ b/libc/bionic/malloc_limit.cpp
@@ -253,6 +253,10 @@
 }
 #endif
 
+bool MallocLimitInstalled() {
+  return GetDispatchTable() == &__limit_dispatch;
+}
+
 #if defined(LIBC_STATIC)
 static bool EnableLimitDispatchTable() {
   // This is the only valid way to modify the dispatch tables for a