Driver Verifier on Win2003Server SP1 is tossing a fatal error about failure to
release non-paged pool in my driver unload routine. Verifier on XP-SP2 sees no
such failure, but since it is claimed that Verifier on W2K3 is “better”, I spent
some time trying to track down the problem in my driver.
The first thing I noticed is that the windbg cmd: !verifier 3 mydriver.sys shows
a legitimate “unreleased NPP block” size, but when I look at the location that
allocation was made from, it is something nonsensical like:
mydriver!ExAllocateFromNPagedLookasideList+0x51
[c:\winddk\3790.1830\inc\ddk\wnet\ntddk.h @ 15317]:
This leads me to believe that the allocation info that verifier is capturing is
not the same as the XPSP2 verifier (which gives me the location in my driver
where the allocation occurs, not the address of the allocation routine).
In any case, I stepped through my driver’s code, with a bp on any type of pool
allocation, and found only one ExInitializeNPagedLookasideList call, several
allocations and frees from the LAL, and a ExDeleteNPagedLookasideList call in
the unload. It is not guaranteed that the allocations from the LAL have a
matching number of frees to the LAL, however.
Verifier’s “LAL leak” suggests that documentation on the LookasideList stuff may
not be correct with regard to the behavior of ExDeleteNPagedLookasideList. It
appears that the docs do not care whether or not ExFreeToNPagedLookasideList was
used to return any outstanding LAL allocations before deleting the LAL itself.
While good programming practice would be to free any pointers to LAL blocks that
were allocated from the LAL, after deleting the LAL, it is sufficient to just
avoid using any outstanding pointers to LAL blocks afte the delete. The reason I
believe this is that the docs (WXP-SP2 and W2K3-SP1 DDKs) both state only that
“Drivers must always use explicitly free any lookaside lists they create before
unloading”, and don’t even imply that allocated LAL block pointer must be freed
first.
Is this new difference in behavior between Win2003ServerSP1 and earlier OS LAL
implementation just a major flaw in the docs??? I’m also interested in whether
or not verifier’s failure to save the address of my driver’s LAL allocation call
is a new behavior or just an “issue”.
Suggestions, comments …
Jerry Schneider