[compiler-rt] [asan] Add experimental 'poison_history_size' flag (PR #133175)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 10:07:00 PDT 2025
================
@@ -600,6 +602,42 @@ static void PrintShadowMemoryForAddress(uptr addr) {
Printf("%s", str.data());
}
+static void CheckPoisonRecords(uptr addr) {
+ if (!AddrIsInMem(addr))
+ return;
+ uptr shadow_addr = MemToShadow(addr);
+ unsigned char poison_magic = *(reinterpret_cast<u8 *>(shadow_addr));
+
+ if (poison_magic != kAsanUserPoisonedMemoryMagic)
+ return;
+
+ Printf("\n");
+
+ if (flags()->poison_history_size <= 0) {
+ Printf(
+ "NOTE: the stack trace above identifies the code that *accessed* "
+ "the poisoned memory.\n");
+ Printf(
+ "To identify the code that *poisoned* the memory, try the "
+ "experimental setting ASAN_OPTIONS=poison_history_size=<size>.\n");
+ return;
+ }
+
+ struct PoisonRecord record;
+ if (FindPoisonRecord(addr, record)) {
+ StackTrace poison_stack = StackDepotGet(record.stack_id);
+ if (poison_stack.size == 0) {
+ Printf("ERROR: stack depot did not have a matching stack.\n");
----------------
vitalybuka wrote:
> "ERROR: stack depot did not have a matching stack.\n"
I would not consider this an error. Information is just not avalible.
I'd just quietly print nothing,
https://github.com/llvm/llvm-project/pull/133175
More information about the llvm-commits
mailing list