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

Etienne Bergeron via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 14 10:18:41 PST 2017


etienneb added inline comments.


================
Comment at: lib/asan/asan_win.cc:282
+  MEMORY_BASIC_INFORMATION mem_info = {};
+  if (::VirtualQuery((LPVOID)addr, &mem_info, sizeof(mem_info)) == 0 ||
+      mem_info.State == MEM_FREE) {
----------------
rnk wrote:
> etienneb wrote:
> > rnk wrote:
> > > This is too broad. This will suppress invalid free checks on any pointer from VirtualAlloc. Why not use HeapValidate? It appears to support checking a single block efficiently: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366708(v=vs.85).aspx
> > Are we assuming?
> >  1) no custom memory management (direct access to virtual-alloc/free)?
> >  2) no other heap (only the default process heap
> > 
> > And I'm not sure |lpMem| can be any arbitrary pointer within the memory chunk. I suspect it must be the begining of the block.
> We only come here when someone calls `free` in the CRT. That means they must be using the system heap. ASan assumes it's the only code hotpatching the system heap. We only want to suppress invalid free reports on pointers to blocks of memory allocated on the system heap from before ASan initialized. Any other pointer should generate an invalid free report.
You're right, this is for Free(...).
I'm gonna add a comment to  |IsSystemHeapAddress |.


https://reviews.llvm.org/D25946





More information about the llvm-commits mailing list