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/DebugData.cpp b/libc/malloc_debug/DebugData.cpp
index d6ca998..76f8fbb 100644
--- a/libc/malloc_debug/DebugData.cpp
+++ b/libc/malloc_debug/DebugData.cpp
@@ -94,16 +94,25 @@
if (track != nullptr) {
track->PrepareFork();
}
+ if (free_track != nullptr) {
+ free_track->PrepareFork();
+ }
}
void DebugData::PostForkParent() {
if (track != nullptr) {
track->PostForkParent();
}
+ if (free_track != nullptr) {
+ free_track->PostForkParent();
+ }
}
void DebugData::PostForkChild() {
if (track != nullptr) {
track->PostForkChild();
}
+ if (free_track != nullptr) {
+ free_track->PostForkChild();
+ }
}