-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
[lsan] Fix compilation on Android #113003
Merged
vitalybuka
merged 6 commits into
main
from
users/vitalybuka/spr/lsan-fix-compilation-on-android
Oct 19, 2024
Merged
[lsan] Fix compilation on Android #113003
vitalybuka
merged 6 commits into
main
from
users/vitalybuka/spr/lsan-fix-compilation-on-android
Oct 19, 2024
+5
−4
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesFull diff: https://github.com/llvm/llvm-project/pull/113003.diff 1 Files Affected:
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)
|
You can test this locally with the following command:git-clang-format --diff 0138adb68fc20c2fd1a368ca3a2e531debed3852 1d2d59719ca0900ec1cfb330c1f7e9c7ecec5b63 --extensions cpp -- compiler-rt/lib/lsan/lsan_common.cpp View the diff from clang-format here.diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp
index 17d1d5c642..5c44c000ae 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -525,7 +525,8 @@ 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
|
vitalybuka
added
the
skip-precommit-approval
PR for CI feedback, not intended for review
label
Oct 19, 2024
vitalybuka
deleted the
users/vitalybuka/spr/lsan-fix-compilation-on-android
branch
October 19, 2024 01:40
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler-rt:lsan
Leak sanitizer
compiler-rt:sanitizer
compiler-rt
skip-precommit-approval
PR for CI feedback, not intended for review
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.