<div>Shouldn't the implementation of `PlatformIsValidAddress` Be `UNIMEMENTED();` on non-Wibdows? That way we're sure we don't call it by mistake.</div><div><br></div><div>Thank you,</div><div><br></div><div> Filipe</div><div><br><div class="gmail_quote"><div>On Tue, 14 Feb 2017 at 18:18, Etienne Bergeron via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">etienneb added inline comments.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: lib/asan/asan_win.cc:282<br class="gmail_msg">
+  MEMORY_BASIC_INFORMATION mem_info = {};<br class="gmail_msg">
+  if (::VirtualQuery((LPVOID)addr, &mem_info, sizeof(mem_info)) == 0 ||<br class="gmail_msg">
+      mem_info.State == MEM_FREE) {<br class="gmail_msg">
----------------<br class="gmail_msg">
rnk wrote:<br class="gmail_msg">
> etienneb wrote:<br class="gmail_msg">
> > rnk wrote:<br class="gmail_msg">
> > > 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: <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa366708(v=vs.85).aspx" rel="noreferrer" class="gmail_msg" target="_blank">https://msdn.microsoft.com/en-us/library/windows/desktop/aa366708(v=vs.85).aspx</a><br class="gmail_msg">
> > Are we assuming?<br class="gmail_msg">
> >  1) no custom memory management (direct access to virtual-alloc/free)?<br class="gmail_msg">
> >  2) no other heap (only the default process heap<br class="gmail_msg">
> ><br class="gmail_msg">
> > 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.<br class="gmail_msg">
> 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.<br class="gmail_msg">
You're right, this is for Free(...).<br class="gmail_msg">
I'm gonna add a comment to  |IsSystemHeapAddress |.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D25946" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D25946</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
llvm-commits mailing list<br class="gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="gmail_msg">
</blockquote></div></div>