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
This commit is contained in:
Iris Chang 2019-03-07 12:32:19 +08:00
parent ff16c0b89b
commit 76dcc478d3
1 changed files with 1 additions and 1 deletions

View File

@ -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 {