Novell is now a part of Micro Focus

Isolating NLM memory allocation errors...

Novell Cool Solutions: Tip

Digg This - Slashdot This

Posted: 21 Nov 2000

A useful feature in NetWare 5 is the '-m' module loader option, which can be applied to any NLM module to help track down memory allocation errors.

The '-m' switch tells the NetWare OS that every time your NLM does some memory allocation, one or more full memory pages will be allocated, with a guard page at the border of the upper address of the allocated memory. If a subsequent memory read overruns and touches the guard page, a page fault will occur, causing the server to abend exactly on the instruction that overran the memory.

If, for example, you allocate 32 bytes of memory with malloc(32), the OS will actually allocate a full page of memory, plus a guard page. The pointer returned by malloc() will point to memory which is 32 bytes from the end of the allocated page. This way, if your code erroneously tries to read, say, 33 bytes from this area, the guard page will be touched, and a page fault will occur.

The syntax for using this feature is:

    LOAD -m

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates