I have a KMDF driver that is leaking non-paged pool memory and Driver
Verifier isn’t catching it.
:
:
:
Initially I used Task Manager to detect a memory leak with an application
using my KMDF driver. The commit size and NP Pool size both went up in the
same amounts. This happened both on XP (single core) and Vista (dual core)
but the Vista (quad core) showed no memory leak using Task Manager (bug
???).
Next I used Poolmon.exe to track memory allocations using the tag I’ve
assigned for my KMDF driver. In XP I used gflags.exe to first enable pool
tagging. Gflags.exe in Vista showed pool tagging already enabled. Sure
enough, on all three boxes the NP Pool size for my KMDF driver just kept on
growing.
I was pretty sure I had used Driver Verifier on my KMDF driver for the past
month in regular usage but now I started to second guess myself. I checked
Driver Verifier and the information collected for my KMDF driver showed ‘0’
for all NP pool memory counters.
I then added Driver Verifier standard settings for the wdf01000.sys driver
and rebooted. I checked Driver Verifier information collected for my KMDF
driver and again showed ‘0’ for all NP pool memory counters. However, the
NP pool memory counters for wdf01000.sys continually went up. Why didn’t
Driver Verifier issue a stop???
I used sysinternals Strings program on wdf01000.sys to see if I could match
a character string to a tag in poolmon.exe (no luck). I then looked at
highlighted tags in Vista (quad core) to see if any of the highlighted large
differences in memory (allocation versus frees) had a tag name that might be
associated to wdf01000.sys. I found a lot of highlighted tags that had
large differences but none I could point to and say it was the wdf01000.sys
tag. Here are just some of the tags with large differences.
CcSc NP
Even NP
FIcs P
FOCX NP
File NP
HBIH NP -----> my KMDF driver
Io NP
IoNm P
:
:
My summation up to this point is that my KMDF driver is leaking NP pool
memory through the wdf01000.sys driver and I need to find out how. My
confidence in Driver Verifier has slipped quite a bit because it didn’t
catch the memory leak in my driver on any of the 3 boxes even though both
Poolmon.exe and Task Manager showed a leak. Also, Driver Verifier didn’t
stop when wdf01000.sys showed what looked like a leak. If I knew what the
tag was for wdf01000.sys I would have tried to verify the leak in
Poolmon.exe but I couldn’t find a tag.
NOTE: I haven’t tried the new Static Driver Verifier in the latest WinHec
bits but I will very soon. I’m hoping that might find the memory leak. I
did have some PreFast warnings listed below but they don’t seem to be
related to this.
c:\winddk\6000\inc\wdf\kmdf\10\wdfinterrupt.h (278): warning 28104: The
Interrupt that should have been acquired before function exit was not
acquired.
FUNCTION: WdfInterruptAcquireLock (278)
PATH: 283
c:\winddk\6000\inc\wdf\kmdf\10\wdfinterrupt.h (278): warning 28158: No IRQL
was saved into ‘Interrupt’.
FUNCTION: WdfInterruptAcquireLock (278)
PATH: 283
c:\winddk\6000\inc\wdf\kmdf\10\wdfinterrupt.h (299): warning 28103: Leaking
the Interrupt stored in ‘Interrupt’.
FUNCTION: WdfInterruptReleaseLock (299)
PATH: 304
c:\winddk\6000\inc\wdf\kmdf\10\wdfinterrupt.h (299): warning 28157: The IRQL
in ‘Interrupt’ was never restored.
FUNCTION: WdfInterruptReleaseLock (299)
PATH: 304
c:\winddk\6000\inc\wdf\kmdf\10\wdfsync.h (184): warning 28104: The SpinLock
that should have been acquired before function exit was not acquired.
FUNCTION: WdfSpinLockAcquire (184)
PATH: 189
c:\winddk\6000\inc\wdf\kmdf\10\wdfsync.h (184): warning 28158: No IRQL was
saved into ‘SpinLock’.
FUNCTION: WdfSpinLockAcquire (184)
PATH: 189
c:\winddk\6000\inc\wdf\kmdf\10\wdfsync.h (205): warning 28103: Leaking the
SpinLock stored in ‘SpinLock’.
FUNCTION: WdfSpinLockRelease (205)
PATH: 210
c:\winddk\6000\inc\wdf\kmdf\10\wdfsync.h (205): warning 28157: The IRQL in
‘SpinLock’ was never restored.
FUNCTION: WdfSpinLockRelease (205)
PATH: 210
d:\user\winsoft\hib\drivers\hibusbwdf\sys\objfre_wxp_x86\i386\hibusb.tmh
(1829): warning 6387: (PFD)‘pDevObject’ could be ‘0’: this does not adhere
to the specification for the function ‘WdfDriverRegisterTraceInfo’.
FUNCTION: WppInitKm (1784)
PATH: 1806 1807 1810 1814 1829