summaryrefslogtreecommitdiff
path: root/libc/malloc_debug/DebugData.cpp
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-02-07 22:51:15 -0800
committerColin Cross <ccross@android.com>2016-02-12 16:41:14 -0800
commit7a28a3cf1f8df36e30724e8b4021cddde0596118 (patch)
tree2add78d5dcf97d4cb4f360fba7b512656be70313 /libc/malloc_debug/DebugData.cpp
parent9750a77b31f2fc6d548a02b3a9750c2794648fea (diff)
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. Change-Id: I0dfed30045a28551217ceac227d33b2e18894932
Diffstat (limited to 'libc/malloc_debug/DebugData.cpp')
-rw-r--r--libc/malloc_debug/DebugData.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libc/malloc_debug/DebugData.cpp b/libc/malloc_debug/DebugData.cpp
index bf2a0f5e5..cf16c29ac 100644
--- a/libc/malloc_debug/DebugData.cpp
+++ b/libc/malloc_debug/DebugData.cpp
@@ -82,3 +82,21 @@ bool DebugData::Initialize() {
}
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();
+ }
+}