malloc_debug: reset TrackData mutex after fork

Add a pthread_atfork handler to malloc_debug to lock the TrackData mutex
during fork and reset it in the child.  Ensures that the TrackData is
consistent when forking from a multi-threaded process, and that the
mutex is in a defined state in the child.

Bug: 27208635
(cherry picked from commit 7a28a3cf1f8df36e30724e8b4021cddde0596118)

Change-Id: I84bc67be09b8b767e1cf2f14141e2ae8dc4fb462
diff --git a/libc/malloc_debug/DebugData.cpp b/libc/malloc_debug/DebugData.cpp
index 92b866d..0447566 100644
--- a/libc/malloc_debug/DebugData.cpp
+++ b/libc/malloc_debug/DebugData.cpp
@@ -82,3 +82,21 @@
   }
   return true;
 }
+
+void DebugData::PrepareFork() {
+  if (track != nullptr) {
+    track->PrepareFork();
+  }
+}
+
+void DebugData::PostForkParent() {
+  if (track != nullptr) {
+    track->PostForkParent();
+  }
+}
+
+void DebugData::PostForkChild() {
+  if (track != nullptr) {
+    track->PostForkChild();
+  }
+}