summaryrefslogtreecommitdiff
path: root/lib/lsan/lsan_common.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-09-19 19:52:57 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-09-19 19:52:57 +0000
commitdc2e8074dc573a070e71da4be3d97c5f6b765dba (patch)
treec8d2c70dd7a4ac0503148c7a052078c9c9645a79 /lib/lsan/lsan_common.cpp
parenta5996120c6cf50aaaa9f137945ae07176f37b612 (diff)
downloadcompiler-rt-dc2e8074dc573a070e71da4be3d97c5f6b765dba.tar.gz
[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
Diffstat (limited to 'lib/lsan/lsan_common.cpp')
-rw-r--r--lib/lsan/lsan_common.cpp6
1 files changed, 1 insertions, 5 deletions
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, &param);
- UnlockAllocator();
- UnlockThreadRegistry();
+ LockStuffAndStopTheWorld(CheckForLeaksCallback, &param);
if (!param.success) {
Report("LeakSanitizer has encountered a fatal error.\n");