asan_memory_profile: Fix for deadlock in memory profiler code.
authorSanjeet Karan Singh <ssingh6@ciena.com>
Sat, 1 Apr 2023 03:36:34 +0000 (20:36 -0700)
committerVitaly Buka <vitalybuka@google.com>
Sat, 1 Apr 2023 04:10:34 +0000 (21:10 -0700)
commit129394ff50ed28a0b85d742c8ae315758bb22582
treebc2fa920fbfa225d7cdf8d5e36a7714327715a89
parent88db195695215e920a63e197517103b4b9744445
asan_memory_profile: Fix for deadlock in memory profiler code.

Wrapping stopTheWorld in dl_iterate_phdr acquire dl_load lock before
calling the function. Acquiring dl_load, allocator and thread registry
locks before calling stopTheWorld ensures no other threads are holding
that locks, we can safely suspend them and reenter in tracer thread.
LockStuffAndStopTheWorld's logic here is same as lsan's implementation
of this function.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D146990
compiler-rt/lib/asan/asan_memory_profile.cpp