[compiler-rt] [hwasan] Fix DCHECK with COMPILER_RT_DEBUG=ON (PR #84612)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 23:57:18 PST 2024


https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/84612

It appears this assertion should actually be checking that the pointer
is aligned to `sz` bytes rather than the shadow alignment, since
otherwise the `(ptr & (kShadowAlignment - 1))` mask would always be 0.


>From 4732f91f0de661f61bffc4714b77f2e0afffd281 Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Fri, 8 Mar 2024 23:57:05 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 compiler-rt/lib/hwasan/hwasan_checks.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/hwasan/hwasan_checks.h b/compiler-rt/lib/hwasan/hwasan_checks.h
index 0911af30dcb8fc..7067e7140e7bef 100644
--- a/compiler-rt/lib/hwasan/hwasan_checks.h
+++ b/compiler-rt/lib/hwasan/hwasan_checks.h
@@ -140,7 +140,7 @@ __attribute__((always_inline, nodebug)) static inline uptr ShortTagSize(
 
 __attribute__((always_inline, nodebug)) static inline bool
 PossiblyShortTagMatches(tag_t mem_tag, uptr ptr, uptr sz) {
-  DCHECK(IsAligned(ptr, kShadowAlignment));
+  DCHECK(IsAligned(ptr, sz));
   tag_t ptr_tag = GetTagFromPointer(ptr);
   if (ptr_tag == mem_tag)
     return true;



More information about the llvm-commits mailing list