From 1a8106ec1aba6a5317f3dbfc3e8073630c18975b Mon Sep 17 00:00:00 2001 From: Denis Hsu Date: Mon, 15 Jan 2018 18:49:01 +0800 Subject: 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 --- libc/malloc_debug/DebugData.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libc/malloc_debug/DebugData.cpp') diff --git a/libc/malloc_debug/DebugData.cpp b/libc/malloc_debug/DebugData.cpp index d6ca99886..76f8fbb1e 100644 --- a/libc/malloc_debug/DebugData.cpp +++ b/libc/malloc_debug/DebugData.cpp @@ -94,16 +94,25 @@ void DebugData::PrepareFork() { 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(); + } } -- cgit v1.2.3