From dc2e8074dc573a070e71da4be3d97c5f6b765dba Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Thu, 19 Sep 2019 19:52:57 +0000 Subject: [lsan] Fix deadlock in dl_iterate_phdr. Summary: Do not grab the allocator lock before calling dl_iterate_phdr. This may cause a lock order inversion with (valid) user code that uses malloc inside a dl_iterate_phdr callback. Reviewers: vitalybuka, hctim Subscribers: jfb, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D67738 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@372348 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/lsan/lsan_common.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/lsan/lsan_common.cpp') diff --git a/lib/lsan/lsan_common.cpp b/lib/lsan/lsan_common.cpp index 86bd120e7..9ff9f4c5d 100644 --- a/lib/lsan/lsan_common.cpp +++ b/lib/lsan/lsan_common.cpp @@ -570,11 +570,7 @@ static bool CheckForLeaks() { EnsureMainThreadIDIsCorrect(); CheckForLeaksParam param; param.success = false; - LockThreadRegistry(); - LockAllocator(); - DoStopTheWorld(CheckForLeaksCallback, ¶m); - UnlockAllocator(); - UnlockThreadRegistry(); + LockStuffAndStopTheWorld(CheckForLeaksCallback, ¶m); if (!param.success) { Report("LeakSanitizer has encountered a fatal error.\n"); -- cgit v1.2.1