Hi all
I am working on usb driver that creates a buffer with(ExAllocatePoolWithTag) when the usb device starts (IRP_MN_START_DEVICE) and it does not release the buffer until the IRP_MN_STOP_DEVICE or IRP_MN_SURPRISE_REMOVAL gets called.
Running the test Disable Enable IO gives a verifier blue screen telling me the buffer has not be released.
Poolmon does show the unreleased buffer until I power down the device. Is it ok to keep buffers throught the devices’ life?
Why is verifier not happy? I can see in the logs that the test starts with stopping the device, and ends up starting the device(which causes an extra buffer that will be released as soon as the device gets powered off)
A disable/enable test will send you a query remove -> remove irp sequence, no stop or surprise removal irps. A stop irp is only sent when there is a pnp rebalance of hw resources, not when your device is disabled or the user chooses to update the driver. You need to free the buffer on IRP_MN_REMOVE_DEVICE if you have not already done so in IRP_MN_SURPRISE_REMOVAL (but in all honesty, you should just remove the call to free the pool from IRP_MN_SURPRISE_REMOVAL) and just do it in IRP_MN_REMOVE_DEVICE
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, January 25, 2010 1:58 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] weird memory leak verifier wrong?
Hi all
I am working on usb driver that creates a buffer with(ExAllocatePoolWithTag) when the usb device starts (IRP_MN_START_DEVICE) and it does not release the buffer until the IRP_MN_STOP_DEVICE or IRP_MN_SURPRISE_REMOVAL gets called.
Running the test Disable Enable IO gives a verifier blue screen telling me the buffer has not be released.
Poolmon does show the unreleased buffer until I power down the device. Is it ok to keep buffers throught the devices’ life?
Why is verifier not happy? I can see in the logs that the test starts with stopping the device, and ends up starting the device(which causes an extra buffer that will be released as soon as the device gets powered off)
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
if I just do it in IRP_MN_REMOVE_DEVICE the Pnp rebalances test fails I think I should do it in both carefully…
Well, I am guessing you blindly allocate the memory in IRP_MN_START_DEVICE, so either you check if you have a valid allocation on restart or you free on stop. I would recommend that you do not free any resources on stop so that restart will not fail due to allocation failures
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, January 25, 2010 2:51 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] weird memory leak verifier wrong?
if I just do it in IRP_MN_REMOVE_DEVICE the Pnp rebalances test fails I think I should do it in both carefully…
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Thought I still think there is something weird with the test my code does clean up in IRP_MN_REMOVE_DEVICE but the last 2 IRP the test sends are :
- IRP_MN_QUERY_CAPABILITIES followed by
- IRP_MN_QUERY_CAPABILITIES again
Granted I am not doing anything with IRP_MN_QUERY_CAPABILITIES but IRP_MN_REMOVE_DEVICE nor IRP_MN_QUERY_REMOVE_DEVICE gets called at the end of the test.
Unless I am handling RP_MN_QUERY_CAPABILITIES wrong my driver will never past the test?!?
Query caps has nothing to do with the test, anyone can send a query caps. There are only two ways to get to irp_mn_remove_device, either query remove -> remove or surprise removal -> remove. That’s it. I would also strongly suggest you look at KMDF, it takes care of all of this for you.
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, January 25, 2010 3:13 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] weird memory leak verifier wrong?
Thought I still think there is something weird with the test my code does clean up in IRP_MN_REMOVE_DEVICE but the last 2 IRP the test sends are :
- IRP_MN_QUERY_CAPABILITIES followed by
- IRP_MN_QUERY_CAPABILITIES again
Granted I am not doing anything with IRP_MN_QUERY_CAPABILITIES but IRP_MN_REMOVE_DEVICE nor IRP_MN_QUERY_REMOVE_DEVICE gets called at the end of the test.
Unless I am handling RP_MN_QUERY_CAPABILITIES wrong my driver will never past the test?!?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer