[compiler-rt] [lsan] Fix compilation on Android (PR #113003)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 16:36:31 PDT 2024
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/113003
>From 5c9dedcec9dd92432c6f6cf528d6fe99f43db616 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 18 Oct 2024 16:26:17 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
=?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
compiler-rt/lib/lsan/lsan_common.cpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp
index 9aed36b96ce929..c54c1a7cc4930c 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -373,10 +373,10 @@ void ScanGlobalRange(uptr begin, uptr end, Frontier *frontier) {
}
template <class Accessor>
-void ScanExtraStack(const InternalMmapVector<Range> &ranges, Frontier *frontier,
- Accessor &accessor) {
+void ScanRanges(const InternalMmapVector<Range> &ranges, Frontier *frontier,
+ const char *region_type, Accessor &accessor) {
for (uptr i = 0; i < ranges.size(); i++) {
- ScanForPointers(ranges[i].begin, ranges[i].end, frontier, "FAKE STACK",
+ ScanForPointers(ranges[i].begin, ranges[i].end, frontier, region_type,
kReachable, accessor);
}
}
@@ -384,7 +384,7 @@ void ScanExtraStack(const InternalMmapVector<Range> &ranges, Frontier *frontier,
void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges,
Frontier *frontier) {
DirectMemoryAccessor accessor;
- ScanExtraStack(ranges, frontier, accessor);
+ ScanRanges(ranges, frontier, "FAKE STACK", accessor);
}
# if SANITIZER_FUCHSIA
@@ -478,7 +478,7 @@ static void ProcessThread(tid_t os_id, uptr sp,
ScanForPointers(stack_begin, stack_end, frontier, "STACK", kReachable,
accessor);
GetThreadExtraStackRangesLocked(os_id, &extra_ranges);
- ScanExtraStack(extra_ranges, frontier, accessor);
+ ScanRanges(extra_ranges, frontier, "FAKE STACK", accessor);
}
if (flags()->use_tls) {
@@ -500,13 +500,13 @@ static void ProcessThread(tid_t os_id, uptr sp,
}
}
# if SANITIZER_ANDROID
+ extra_ranges.clear();
auto *cb = +[](void *dtls_begin, void *dtls_end, uptr /*dso_idd*/,
void *arg) -> void {
- ScanForPointers(
- reinterpret_cast<uptr>(dtls_begin), reinterpret_cast<uptr>(dtls_end),
- reinterpret_cast<Frontier *>(arg), "DTLS", kReachable, accessor);
+ reinterpret_cast<InternalMmapVector<Range> *>(arg)->push_back(
+ reinterpret_cast<uptr>(dtls_begin), reinterpret_cast<uptr>(dtls_end));
};
-
+ ScanRanges(extra_ranges, frontier, "DTLS", accessor);
// FIXME: There might be a race-condition here (and in Bionic) if the
// thread is suspended in the middle of updating its DTLS. IOWs, we
// could scan already freed memory. (probably fine for now)
>From 24890a7cd247da0390803e33dda4408b4e9db1fc Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 18 Oct 2024 16:29:34 -0700
Subject: [PATCH 2/2] fix
Created using spr 1.3.4
---
compiler-rt/lib/lsan/lsan_common.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp
index c54c1a7cc4930c..4c06b8132aad15 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -504,7 +504,7 @@ static void ProcessThread(tid_t os_id, uptr sp,
auto *cb = +[](void *dtls_begin, void *dtls_end, uptr /*dso_idd*/,
void *arg) -> void {
reinterpret_cast<InternalMmapVector<Range> *>(arg)->push_back(
- reinterpret_cast<uptr>(dtls_begin), reinterpret_cast<uptr>(dtls_end));
+ {reinterpret_cast<uptr>(dtls_begin), reinterpret_cast<uptr>(dtls_end)});
};
ScanRanges(extra_ranges, frontier, "DTLS", accessor);
// FIXME: There might be a race-condition here (and in Bionic) if the
More information about the llvm-commits
mailing list