[compiler-rt] 1e6d135 - [scudo] Untag pointer in iterateOverChunks

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 12:45:13 PDT 2021


Author: Vitaly Buka
Date: 2021-06-04T12:45:07-07:00
New Revision: 1e6d135325357d8c32fd0b0d7f668cad91d478bc

URL: https://github.com/llvm/llvm-project/commit/1e6d135325357d8c32fd0b0d7f668cad91d478bc
DIFF: https://github.com/llvm/llvm-project/commit/1e6d135325357d8c32fd0b0d7f668cad91d478bc.diff

LOG: [scudo] Untag pointer in iterateOverChunks

Pointer comparison in Lambda will not work on tagged pointers.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D103496

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/combined.h
    compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index f58eaa945af3..079edab1875b 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -727,6 +727,8 @@ class Allocator {
   void iterateOverChunks(uptr Base, uptr Size, iterate_callback Callback,
                          void *Arg) {
     initThreadMaybe();
+    if (archSupportsMemoryTagging())
+      Base = untagPointer(Base);
     const uptr From = Base;
     const uptr To = Base + Size;
     bool MayHaveTaggedPrimary = allocatorSupportsMemoryTagging<Params>() &&

diff  --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
index eed8f0319337..62410fc393ae 100644
--- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "memtag.h"
 #include "scudo/interface.h"
 #include "tests/scudo_unit_test.h"
 
@@ -277,6 +278,10 @@ static uintptr_t BoundaryP;
 static size_t Count;
 
 static void callback(uintptr_t Base, size_t Size, void *Arg) {
+  if (scudo::archSupportsMemoryTagging()) {
+    Base = scudo::untagPointer(Base);
+    BoundaryP = scudo::untagPointer(BoundaryP);
+  }
   if (Base == BoundaryP)
     Count++;
 }


        


More information about the llvm-commits mailing list