Re: C++ in KMDF

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Doron Holan [MSFT]" wrote:
are you sure it works for 64 bits if the size parameter is enregistered?
the address of the register is not going to give you the caller's stack is
it? Besides, there is a compiler intrinsic which will give you the caller's
address with out pointer trickery. The problem with new localizing all
allocations to one function is not that you can work around the issue by
capturing the caller's address, it is that other tools which do not know to
jump up one stack location are affected. for instance, driver verifier will
report all allocations coming from your operator new() and you then have to
manually inspect the pool on your own to find the real caller (if it is even
stored on a fre build)

Actually, I don't know because I've never had a memory leak in the
64-bit version of one of my drivers. All the leaks got plugged while
testing in 32-bits. But for future reference, what's the intrinsic?

I don't much care if verifier gets the wrong address because verifier
never sees a memory leak unless the release build has a bug that wasn't
in the debug build. My debug cleanup reports the leak via an ASSERT and
then ExFreePool's the allocation. This has never failed to find all the
leaks in years of driver writing. Mind you, I only went down this path
because I needed to be able to debug drivers on my laptop while
travelling, and that meant using Soft-Ice, and that meant needing a way
to keep a verifier error from bug-checking on the very first error.

--
Walter Oney, Consulting and Training
http://www.oneysoft.com
.



Relevant Pages

  • Re: Two drivers attached to same thread ?
    ... It makes to me feel that Norton's drivers are not verifier compatible, and thus, very unreliable. ... I also had problems with symevent.sys driver. ... due to stack overflow(which was confirmed by looking at ESP and stack ... This means a trap occurred in kernel mode, and it's a trap of a kind ...
    (microsoft.public.win32.programmer.kernel)
  • Re: IRP tag nonpaged pool memory Leak
    ... faulty driver or a leaky driver, every driver seemed to free the memory it ... Verifier kept on telling me to add more memory, ... I have a nonpaged pool memory leak for the Irp tag, ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: WINDBG:Memory access error
    ... Could be a severe memory overrun. ... Try to run your driver with verifier, it will catch problem before your driver will make something really bad. ... value assigned to all parameters of Driver Entry routine in the stack. ...
    (microsoft.public.development.device.drivers)
  • Re: Memory leak in the Driver
    ... Paul G. Tobey wrote: ... driver development, it's most likely that you are at fault. ... The QFE has no impact on the leak but one thing is sure, ... i am sure that all the memory that i am allocating in my driver is ...
    (microsoft.public.windowsce.platbuilder)
  • Checking resource leaks in a form
    ... We can use the below procedure to check if a form is having resource leak. ... Open Windows Task Manager ... AppVerifier on CE5.0 - to detect memory leaks in a driver ... The application used an invalid heap handle. ...
    (microsoft.public.windowsce.embedded)