[NFC][asan] Extract out RecordPoison helper function#195672
Merged
vitalybuka merged 4 commits intoMay 4, 2026
Merged
Conversation
Created using spr 1.3.7 [skip ci]
Created using spr 1.3.7
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesFull diff: https://github.com/llvm/llvm-project/pull/195672.diff 1 Files Affected:
diff --git a/compiler-rt/lib/asan/asan_poisoning.cpp b/compiler-rt/lib/asan/asan_poisoning.cpp
index 79457dda1e7c5..fffb3b4ac08f1 100644
--- a/compiler-rt/lib/asan/asan_poisoning.cpp
+++ b/compiler-rt/lib/asan/asan_poisoning.cpp
@@ -138,6 +138,22 @@ void AsanPoisonOrUnpoisonIntraObjectRedzone(uptr ptr, uptr size, bool poison) {
// ---------------------- Interface ---------------- {{{1
using namespace __asan;
+static void RecordPoison(uptr beg_addr, uptr end_addr) {
+ if (LIKELY(beg_addr >= end_addr || flags()->poison_history_size == 0))
+ return;
+ GET_STACK_TRACE(/*max_size=*/16, /*fast=*/false);
+ u32 current_tid = GetCurrentTidOrInvalid();
+
+ u32 stack_id = StackDepotPut(stack);
+
+ PoisonRecord record;
+ record.stack_id = stack_id;
+ record.thread_id = current_tid;
+ record.begin = beg_addr;
+ record.end = end_addr;
+ AddPoisonRecord(record);
+}
+
// Current implementation of __asan_(un)poison_memory_region doesn't check
// that user program (un)poisons the memory it owns. It poisons memory
// conservatively, and unpoisons progressively to make sure asan shadow
@@ -155,19 +171,7 @@ void __asan_poison_memory_region(void const volatile *addr, uptr size) {
VPrintf(3, "Trying to poison memory region [%p, %p)\n", (void *)beg_addr,
(void *)end_addr);
- if (flags()->poison_history_size > 0) {
- GET_STACK_TRACE(/*max_size=*/16, /*fast=*/false);
- u32 current_tid = GetCurrentTidOrInvalid();
-
- u32 stack_id = StackDepotPut(stack);
-
- PoisonRecord record;
- record.stack_id = stack_id;
- record.thread_id = current_tid;
- record.begin = beg_addr;
- record.end = end_addr;
- AddPoisonRecord(record);
- }
+ RecordPoison(beg_addr, end_addr);
ShadowSegmentEndpoint beg(beg_addr);
ShadowSegmentEndpoint end(end_addr);
|
thurstond
approved these changes
May 4, 2026
Created using spr 1.3.7 [skip ci]
moar55
pushed a commit
to moar55/llvm-project
that referenced
this pull request
May 12, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.