[PATCH] D153471: [lsan][Darwin] Unconditionally strip high bits from potential pointers

Leonard Grey via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 14:36:53 PDT 2023


lgrey created this revision.
lgrey added a reviewer: yln.
Herald added subscribers: Enna1, kristof.beyls.
Herald added a project: All.
lgrey requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

The method cache stashes a mask in the high bits under some circumstances:
https://github.com/apple-oss-distributions/objc4/blob/689525d556eb3dee1ffb700423bccf5ecc501dbf/runtime/objc-cache.mm#L589

I'm hitting this now on macOS 13.4 arm64, so we can no longer rely on `OBJC_DATA_MASK` to identify potential pointers that need to be transformed


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153471

Files:
  compiler-rt/lib/lsan/lsan_common.cpp


Index: compiler-rt/lib/lsan/lsan_common.cpp
===================================================================
--- compiler-rt/lib/lsan/lsan_common.cpp
+++ compiler-rt/lib/lsan/lsan_common.cpp
@@ -177,9 +177,7 @@
 // they need to be transformed back into something that looks like a pointer.
 static inline void *MaybeTransformPointer(void *p) {
   uptr ptr = reinterpret_cast<uptr>(p);
-  if ((ptr & OBJC_FAST_IS_RW) == OBJC_FAST_IS_RW)
-    ptr &= OBJC_DATA_MASK;
-  return reinterpret_cast<void *>(ptr);
+  return reinterpret_cast<void *>(ptr & OBJC_DATA_MASK);
 }
 #  endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153471.533404.patch
Type: text/x-patch
Size: 581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230621/fc3f9e0e/attachment.bin>


More information about the llvm-commits mailing list