[compiler-rt] 56876fd - Revert "asan_memory_profile: Fix for deadlock in memory profiler code."
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 3 22:59:15 PDT 2023
Author: Vitaly Buka
Date: 2023-04-03T22:59:02-07:00
New Revision: 56876fdd2e2aeb5676bf983a81e739349d26f835
URL: https://github.com/llvm/llvm-project/commit/56876fdd2e2aeb5676bf983a81e739349d26f835
DIFF: https://github.com/llvm/llvm-project/commit/56876fdd2e2aeb5676bf983a81e739349d26f835.diff
LOG: Revert "asan_memory_profile: Fix for deadlock in memory profiler code."
Deadlocks with internal symbolizer.
https://lab.llvm.org/buildbot/#/builders/37/builds/21181
This reverts commit 129394ff50ed28a0b85d742c8ae315758bb22582.
Added:
Modified:
compiler-rt/lib/asan/asan_memory_profile.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_memory_profile.cpp b/compiler-rt/lib/asan/asan_memory_profile.cpp
index f41d8e1926b4..6c2b7404a279 100644
--- a/compiler-rt/lib/asan/asan_memory_profile.cpp
+++ b/compiler-rt/lib/asan/asan_memory_profile.cpp
@@ -11,18 +11,14 @@
// This file implements __sanitizer_print_memory_profile.
//===----------------------------------------------------------------------===//
-#include "asan/asan_allocator.h"
-#include "lsan/lsan_common.h"
#include "sanitizer_common/sanitizer_common.h"
-#include "sanitizer_common/sanitizer_platform.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "sanitizer_common/sanitizer_stoptheworld.h"
+#include "lsan/lsan_common.h"
+#include "asan/asan_allocator.h"
#if CAN_SANITIZE_LEAKS
-# if SANITIZER_LINUX || SANITIZER_NETBSD
-# include <link.h>
-# endif
namespace __asan {
@@ -115,42 +111,8 @@ static void MemoryProfileCB(const SuspendedThreadsList &suspended_threads_list,
__asan_print_accumulated_stats();
}
-struct DoStopTheWorldParam {
- StopTheWorldCallback callback;
- void *argument;
-};
-
-static void LockDefStuffAndStopTheWorld(DoStopTheWorldParam *param) {
- __lsan::LockThreadRegistry();
- __lsan::LockAllocator();
- __sanitizer::StopTheWorld(param->callback, param->argument);
- __lsan::UnlockAllocator();
- __lsan::UnlockThreadRegistry();
-}
-
#if SANITIZER_LINUX || SANITIZER_NETBSD
-static int LockStuffAndStopTheWorldCallback(struct dl_phdr_info *info,
- size_t size, void *data) {
- DoStopTheWorldParam *param = reinterpret_cast<DoStopTheWorldParam *>(data);
- LockDefStuffAndStopTheWorld(param);
- return 1;
-}
#endif
-
-static void LockStuffAndStopTheWorld(StopTheWorldCallback callback,
- void *argument) {
- DoStopTheWorldParam param = {callback, argument};
-
-# if SANITIZER_LINUX || SANITIZER_NETBSD
- // For libc dep systems, symbolization uses dl_iterate_phdr, which acquire a
- // dl write lock. It could deadlock if the lock is already acquired by one of
- // suspended. So calling stopTheWorld inside dl_iterate_phdr, first wait for
- // that lock to be released (if acquired) and than suspend all threads
- dl_iterate_phdr(LockStuffAndStopTheWorldCallback, ¶m);
-# else
- LockDefStuffAndStopTheWorld(¶m);
-# endif
-}
} // namespace __asan
#endif // CAN_SANITIZE_LEAKS
@@ -163,7 +125,7 @@ void __sanitizer_print_memory_profile(uptr top_percent,
uptr Arg[2];
Arg[0] = top_percent;
Arg[1] = max_number_of_contexts;
- __asan::LockStuffAndStopTheWorld(__asan::MemoryProfileCB, Arg);
+ __sanitizer::StopTheWorld(__asan::MemoryProfileCB, Arg);
#endif // CAN_SANITIZE_LEAKS
}
} // extern "C"
More information about the llvm-commits
mailing list