Catching NULL Pointer Assignments

The nastiest type of bug results from the use of uninitialized or corrupted pointers. The most frequent incorrect value of a pointer is NULL (0). The simplest method to catch these errors is to make the first page of memory inaccessible. Of course, paging must be used to achieve this.

The simplest method is to define a region of 4k size at address 0 and give it NoAccess access rights.

If you don't allocate anything to region FirstPage, RTLoc will append the physical memory page at address 0 to the end of HighMem, making it available for the heap and stack.

However, you should consider that this approach will destroy the real mode interrupt vector table and the real mode BIOS data area. This is usually no problem, but if your program needs to look up some information in this area at run time, you can't use this approach. Instead, region FirstPage would need ReadOnly or ReadWrite access.