[PATCH] D94209: Introduce `UnIgnoreObjectLocked` functions

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 6 17:39:53 PST 2021


delcypher created this revision.
delcypher added reviewers: kubamracek, yln, kcc, dvyukov, eugenis, vitalybuka, cryptoad, earthdok.
delcypher requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

This patch adds implementations for LSan & ASan of new
`UnIgnoreObjectLocked` functions. These functions perform the inverse
of the existing `IgnoreObjectLocked` functions.

These new functions will be used in a later patch to temporarily ignore
a heap object and then unignore it.

rdar://problem/63537240


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94209

Files:
  compiler-rt/lib/asan/asan_allocator.cpp
  compiler-rt/lib/lsan/lsan_allocator.cpp
  compiler-rt/lib/lsan/lsan_common.h


Index: compiler-rt/lib/lsan/lsan_common.h
===================================================================
--- compiler-rt/lib/lsan/lsan_common.h
+++ compiler-rt/lib/lsan/lsan_common.h
@@ -155,6 +155,7 @@
 enum IgnoreObjectResult {
   kIgnoreObjectSuccess,
   kIgnoreObjectAlreadyIgnored,
+  kIgnoreObjectNotAlreadyIgnored,
   kIgnoreObjectInvalid
 };
 
@@ -242,6 +243,7 @@
 uptr GetUserBegin(uptr chunk);
 // Helper for __lsan_ignore_object().
 IgnoreObjectResult IgnoreObjectLocked(const void *p);
+IgnoreObjectResult UnIgnoreObjectLocked(const void *p);
 
 // Return the linker module, if valid for the platform.
 LoadedModule *GetLinker();
Index: compiler-rt/lib/lsan/lsan_allocator.cpp
===================================================================
--- compiler-rt/lib/lsan/lsan_allocator.cpp
+++ compiler-rt/lib/lsan/lsan_allocator.cpp
@@ -316,6 +316,16 @@
   m->tag = kIgnored;
   return kIgnoreObjectSuccess;
 }
+
+IgnoreObjectResult UnIgnoreObjectLocked(const void *p) {
+  ChunkMetadata *m = LookUpValidChunk(p);
+  if (!m)
+    return kIgnoreObjectInvalid;
+  if (m->tag != kIgnored)
+    return kIgnoreObjectNotAlreadyIgnored;
+  m->tag = kDirectlyLeaked;
+  return kIgnoreObjectSuccess;
+}
 } // namespace __lsan
 
 using namespace __lsan;
Index: compiler-rt/lib/asan/asan_allocator.cpp
===================================================================
--- compiler-rt/lib/asan/asan_allocator.cpp
+++ compiler-rt/lib/asan/asan_allocator.cpp
@@ -1190,6 +1190,16 @@
   m->lsan_tag = __lsan::kIgnored;
   return kIgnoreObjectSuccess;
 }
+
+IgnoreObjectResult UnIgnoreObjectLocked(const void *p) {
+  __asan::AsanChunk *m = LookUpValidChunk(p);
+  if (!m)
+    return kIgnoreObjectInvalid;
+  if (m->lsan_tag != kIgnored)
+    return kIgnoreObjectNotAlreadyIgnored;
+  m->lsan_tag = __lsan::kDirectlyLeaked;
+  return kIgnoreObjectSuccess;
+}
 }  // namespace __lsan
 
 // ---------------------- Interface ---------------- {{{1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94209.315032.patch
Type: text/x-patch
Size: 1947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210107/5f12cbee/attachment.bin>


More information about the llvm-commits mailing list