summaryrefslogtreecommitdiff
path: root/libc/malloc_debug/PointerData.cpp
diff options
context:
space:
mode:
authorIris Chang <iris.chang@mediatek.com>2019-03-07 12:32:19 +0800
committerIris Chang <iris.chang@mediatek.com>2019-03-08 11:04:36 +0800
commit76dcc478d348d07fa0e74a7f4d4c1e829eaa2bb8 (patch)
tree0652b53abee71ce853e36b8b0e16c657da7be4da /libc/malloc_debug/PointerData.cpp
parentff16c0b89b7297bc70353f60afac9bb93d6b0087 (diff)
Malloc debug: fix mutex deadlock issue
When we enable free_track option, one thread is in AddFreed->RemoveBacktrace flow (hold free_pointer_mutex_ first and try to lock frame_mutex_), and other thread do fork and enter PrepareFork flow (hold frame_mutex_ first and try to lock free_pointer_mutex_), this situation may result in mutex deadlock issue. Bug: 127733115 Test: build pass and stress test pass Change-Id: Ie5fcc4ef6c169372ad73d81978cfb2a726b6c03e
Diffstat (limited to 'libc/malloc_debug/PointerData.cpp')
-rw-r--r--libc/malloc_debug/PointerData.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp
index 5542c1e9f..6c7d8fa15 100644
--- a/libc/malloc_debug/PointerData.cpp
+++ b/libc/malloc_debug/PointerData.cpp
@@ -601,9 +601,9 @@ void PointerData::DumpLiveToFile(FILE* fp) {
}
void PointerData::PrepareFork() NO_THREAD_SAFETY_ANALYSIS {
+ free_pointer_mutex_.lock();
pointer_mutex_.lock();
frame_mutex_.lock();
- free_pointer_mutex_.lock();
}
void PointerData::PostForkParent() NO_THREAD_SAFETY_ANALYSIS {