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

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 12:56:26 PDT 2016

rnk added inline comments.

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.
samsonov wrote:
> 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).
That's a good idea.

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)) \
samsonov wrote:
> Will this work on older versions of MSVC we're still supporting (if any)?
The override will fail because ucrtbase.dll won't be present in the process, but ASan will continue to work fine. I've tested with VS 2013 and things still work.


More information about the llvm-commits mailing list