Discussion:
AppVerifier and memory block corruption
(too old to reply)
Peter
2007-08-14 17:40:02 UTC
Permalink
I'd like to use AppVerifier to find overrun of alocated memory block on the
heap.
I created simple application with these code:

main(...)
{
char* m=malloc(16);
memset(m,0,17);
}

I have set in AppVerifier test: Basic->Heaps. In Basic->Heap->Properties I
have deafult values. I run application under VC++ debugger, I also tried
WinDbg.
Why AppVerifier does not detect memory corruption ?

Peter
Pavel Lebedinsky [MSFT]
2007-08-17 03:45:44 UTC
Permalink
When a process is started under debugger the OS enables
so called "debug heap" which adds guard bytes after each
allocation to help catch corruptions. This however means that
appverifier/pageheap are not able to detect small overruns
the moment they occur, because the actual user buffer is not
immediately followed by an inaccessible page. Debug CRTs
also have functionality similar to the OS debug heap.

You need to either increase the size of the overrun so that it
crosses the page boundary, or make sure debug CRT is not
used, and process is not launched under debugger (you can
however attach debugger after the process has started).
--
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by Peter
I'd like to use AppVerifier to find overrun of alocated memory block on the
heap.
main(...)
{
char* m=malloc(16);
memset(m,0,17);
}
I have set in AppVerifier test: Basic->Heaps. In Basic->Heap->Properties I
have deafult values. I run application under VC++ debugger, I also tried
WinDbg.
Why AppVerifier does not detect memory corruption ?
opedroso
2009-02-28 17:14:03 UTC
Permalink
If you enable Full Page heap (first checkbox at top of the Properties dialog)
it will on XP32. But your test is lucky, since it will because your original
allocation ends on an 8 byte boundary. On XP64, the allocation would have to
end on a 16 byte boundary (which your also does), but any smaller size would
only be caught if you passed that minimum threshold (8 in XP32, 16 in XP64).
This is due to alignment that the heap has to return the data. You can also
disable that (the Unalign checkbox on the Properties dialog), but most
serious programs will not work with that setting.
Post by Peter
I'd like to use AppVerifier to find overrun of alocated memory block on the
heap.
main(...)
{
char* m=malloc(16);
memset(m,0,17);
}
I have set in AppVerifier test: Basic->Heaps. In Basic->Heap->Properties I
have deafult values. I run application under VC++ debugger, I also tried
WinDbg.
Why AppVerifier does not detect memory corruption ?
Peter
Loading...