True, in many [start, end)
pair algorithm end points past the last valid entry. But your implementation should never dereference end
, the last entry actually accessed should be end-1
, which is guaranteed to be in valid region. If your algorithm dereferences *end
then is a bug. In fact there are test allocators that intentionally place the region on the very last bytes of a valid page, immedeatly followed by an unallocated region. With such allocators an algorithm that dereferences *end
will cause protection fault.
FLG_HEAP_PAGE_ALLOCS
Turns on page heap debugging, which verifies dynamic heap memory
operations, including allocations and frees, and causes a debugger
break when it detects a heap error.
This option enables full page heap debugging when set for image files
and standard page heap debugging when set in system registry or kernel
mode.
Setting this flag for an image file is the same as typing gflags /p
enable /full for the image file at the command line
As for the issue of pointer overfllow: no operating system allocates page containing VA address 0xFFFFFFFF, same way no operating system ever allocates page containing 0x00000000. For such overflow to occur the size of *start
would have to be big enough for start+1
to jump over all the reserved VA at the end of valid ranges. But in such case the addess allocated for start
should be at least one such size below the last valid VA address, and this implies start+1
will be valid (it follows start+N
is also always valid as long as start
was allocated as sizeof(*start)*N
).