[PATCH] D25946: [compiler-rt][asan] Add support for desallocation of unhandled pointers

Etienne Bergeron via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 09:03:25 PDT 2016


etienneb created this revision.
etienneb added a reviewer: rnk.
etienneb added subscribers: chrisha, llvm-commits.
Herald added subscribers: dberris, kubabrecka.

On windows 10, the ucrt DLL is performing allocations before the function hooking and there are multiple allocations not handled by Asan. When a free occur at the end of the process, asan is reporting desallocations not malloc-ed.


https://reviews.llvm.org/D25946

Files:
  lib/asan/asan_allocator.cc


Index: lib/asan/asan_allocator.cc
===================================================================
--- lib/asan/asan_allocator.cc
+++ lib/asan/asan_allocator.cc
@@ -549,6 +549,12 @@
     uptr chunk_beg = p - kChunkHeaderSize;
     AsanChunk *m = reinterpret_cast<AsanChunk *>(chunk_beg);
 
+    // Ignore allocations that are not handled by this allocator. This may
+    // happen when the memory allocation hooking is not able to get full
+    // coverage.
+    if (!get_allocator().PointerIsMine(ptr))
+      return;
+
     ASAN_FREE_HOOK(ptr);
     // Must mark the chunk as quarantined before any changes to its metadata.
     // Do not quarantine given chunk if we failed to set CHUNK_QUARANTINE flag.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25946.75715.patch
Type: text/x-patch
Size: 710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161025/352ce434/attachment.bin>


More information about the llvm-commits mailing list