[PATCH] D18413: [asan] Intercept all Heap* related imports from ucrtbase.dll

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 10:44:24 PDT 2016


samsonov added a reviewer: vitalybuka.

================
Comment at: lib/asan/asan_malloc_win.cc:131
@@ -128,3 +130,3 @@
   (void)sp;
-  return asan_malloc_usable_size(ptr, pc, bp);
+  return asan_malloc_usable_size(const_cast<void *>(ptr), pc, bp);
 }
----------------
I'd rather make asan_malloc_usable_size take a `const void *`

================
Comment at: lib/asan/asan_malloc_win.cc:166
@@ +165,3 @@
+                   SIZE_T dwBytes) {
+  void *p = malloc(dwBytes);
+  // Reading MSDN suggests that the *entire* usable allocation is zeroed out.
----------------
Any reason for not calling asan_malloc, asan_free etc. from these functions directly? E.g. we'll have the allocation stack trace which only contains the top frame from ASan runtime (in this case, HeapAlloc function).

================
Comment at: lib/asan/asan_malloc_win.cc:234
@@ +233,3 @@
+#define INTERCEPT_UCRT_FUNCTION(func)                                         \
+  if (!INTERCEPT_FUNCTION_DLLIMPORT("ucrtbase.dll",                           \
+                                    "api-ms-win-core-heap-l1-1-0.dll", func)) \
----------------
Will this work on older versions of MSVC we're still supporting (if any)?


http://reviews.llvm.org/D18413





More information about the llvm-commits mailing list