malloc debug: reset FreeTrackData mutex after fork

Lock the FreeTrackData mutex during fork and reset it in the child.
Ensures that the FreeTrackData is consistent when forking from a
multi-threaded process, and that the mutex is in a defined state
in the child.

Test: 89hours MTBF test
Change-Id: I5e5892832a733ea85727ec65abc7094d95a725ef
diff --git a/libc/malloc_debug/FreeTrackData.h b/libc/malloc_debug/FreeTrackData.h
index 1758ef5..0e8c177 100644
--- a/libc/malloc_debug/FreeTrackData.h
+++ b/libc/malloc_debug/FreeTrackData.h
@@ -57,6 +57,12 @@
 
   void LogBacktrace(const Header* header);
 
+  void PrepareFork() { pthread_mutex_lock(&mutex_); }
+
+  void PostForkParent() { pthread_mutex_unlock(&mutex_); }
+
+  void PostForkChild() { pthread_mutex_init(&mutex_, NULL); }
+
  private:
   void LogFreeError(const Header* header, const uint8_t* pointer);
   void VerifyAndFree(const Header* header);