-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[nfc][lsan] Restructure loop in ProcessThreads #112609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nfc][lsan] Restructure loop in ProcessThreads #112609
Conversation
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesThe goal is to move Full diff: https://github.com/llvm/llvm-project/pull/112609.diff 1 Files Affected:
diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp
index 6510e0ac3bf6ab..a1a15bf98a1183 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -407,7 +407,20 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
for (uptr i = 0; i < suspended_threads.ThreadCount(); i++) {
registers.clear();
extra_ranges.clear();
+
const tid_t os_id = static_cast<tid_t>(suspended_threads.GetThreadID(i));
+ uptr sp = 0;
+ PtraceRegistersStatus have_registers =
+ suspended_threads.GetRegistersAndSP(i, ®isters, &sp);
+ if (have_registers != REGISTERS_AVAILABLE) {
+ Report("Unable to get registers from thread %llu.\n", os_id);
+ // If unable to get SP, consider the entire stack to be reachable unless
+ // GetRegistersAndSP failed with ESRCH.
+ if (have_registers == REGISTERS_UNAVAILABLE_FATAL)
+ continue;
+ sp = 0;
+ }
+
LOG_THREADS("Processing thread %llu.\n", os_id);
uptr stack_begin, stack_end, tls_begin, tls_end, cache_begin, cache_end;
DTLS *dtls;
@@ -420,20 +433,13 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
LOG_THREADS("Thread %llu not found in registry.\n", os_id);
continue;
}
- uptr sp;
- PtraceRegistersStatus have_registers =
- suspended_threads.GetRegistersAndSP(i, ®isters, &sp);
- if (have_registers != REGISTERS_AVAILABLE) {
- Report("Unable to get registers from thread %llu.\n", os_id);
- // If unable to get SP, consider the entire stack to be reachable unless
- // GetRegistersAndSP failed with ESRCH.
- if (have_registers == REGISTERS_UNAVAILABLE_FATAL)
- continue;
- sp = stack_begin;
- }
+
if (os_id == caller_tid)
sp = caller_sp;
+ if (!sp)
+ sp = stack_begin;
+
if (flags()->use_registers && have_registers) {
uptr registers_begin = reinterpret_cast<uptr>(registers.data());
uptr registers_end =
|
Created using spr 1.3.4 [skip ci]
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/7655 Here is the relevant piece of the build log for the reference
|
flake |
The goal is to move
SuspendedThreadsList
related code intothe beginning of the loop, and prepare for extraction the rest
of the loop body into a function.