Yes, and your point is…?
Can you point to a place in the documentation where pageheap is specified
as having this guarantee? If you find it, it should be reported as a
documentation error.
What I recommend for app programming is for GUI apps to embed in the
message loop
ASSERT(_heapchk() == HEAP_OK);
[disclaimer: I am doing this from memory; check the docs for the correct
names, and if they differ from these, consider this pseudo-code]
That way, if there’s any damage, you have a much better idea which path is
responsible. Then, along that path, sprinkle more of these in strategic
locations.
If you don’t have a GUI app, the generalization of this technique is left
as an Exercise For The Reader.
And why would you think that malloc(1) allocates only one byte?
An all-too-common question in the MFC newsgroup was of the form:
“I’m doing a malloc(1) and according to my calculations I should be able
to do this 1,000,000,000 times without problem. But it fails after NN,NNN
allocations. I have mGB” (usually 4 or 8) “of physical memory. This
should not fail” (How many fundamental errors of understanding can you put
in one question?)
In the debug version of the VS 6 release, malloc(1) allocated 72 bytes of
memory, counting the internal storage headers. Nothing I have ever seen
requires an allocator to do other than meet the request given, and there
is no reason to presume you will get exactly that, or even the value you
asked for rounded up to the next N-byte boundary, for some value of N
being 8 or 16. For example, to minimize fragmentation, the VS 6 release
library would round the string size up to 64, 128, or 256. To avoid
memory fragmentation, I once worked with an allocator that would refuse to
split a block if the resulting free block was smaller than one-sigma from
the mean allocation. It did floating-point computations on a 1968
mainframe because if it saved one page fault it would pay for the slow FPU
on that mainframe.
The idea that gflags could override the alignment is, frankly, dowright
scary. It could break every Interlocked…() in the kernel!
joe
I guess malloc(1) reserves 16 bytes, giving me room to overrun.
This makes me doubt the usefulness of the tool.
It is basically saying “I will catch overruns iff they are big enough”
technically “overrunning the heap manager’s(or whatever) allocation size,
not user sizes”
WINDBG is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer