Answered by:
UMDF 1.9 Issue: Refcount on Continuous reader should be 0

Question
-
I'm trying to fix an old issue in a UMDF version 1.9 package and I'm hoping someone here can assist. During Pnp Remove we observe the following error message in the Windows Debugger:
**** WUDF DriverStop - Internal error 0x500000000000000 **** in Host **** drivers\wdf\umdf\driverhost\framework\v1\wudf\wdfusbpipe.cpp:210(CWdfUsbPipeContinuousReader::~CWdfUsbPipeContinuousReader): Refcount on Continuous reader should be 0, Context Record: .cxr 0x000000739857D810
From my undestanding of the documentation, the DLL is implementing the Continous Reader state management correctly. I have verified IWDFIoTargetStateManagement::Start is called during IPnpCallback::OnD0Entry and that IWDFIoTargetStateManagement::Stop is called during IPnpCallback::OnD0Exit and that references acquired for the callback completion and failure routines have been ->Release()'d.
I have used WdfVerifier to enable Object and Refernce countr tracking and at the point where the debugger breaks, I can see that there are several objects still allocated by the DLL, but none of these appear to be the Continuous Reader itself
0:007> !wudfext.wudfdumpobjects 0x0000025515794fc0 WdfTypeDriver Object: 0x0000025515796f60, Interface: 0x0000025515796fd8 WdfTypeDevice Object: 0x00000255157afc70, Interface: 0x00000255157afce8 WdfTypeIoTarget Object: 0x00000255157bbeb0, Interface: 0x00000255157bbf28 WdfTypeCmResourceList Object: 0x00000255157c6f20, Interface: 0x00000255157c6f98 WdfTypeCmResourceList Object: 0x00000255157cef20, Interface: 0x00000255157cef98 WdfTypeIoQueue Object: 0x00000255157f1ce0, Interface: 0x00000255157f1d58 WdfTypeIoQueue Object: 0x00000255157ffce0, Interface: 0x00000255157ffd58 WdfTypeIoTarget Object: 0x0000025515838e90, Interface: 0x0000025515838f08 WdfTypeFile Object: 0x0000025515843f40, Interface: 0x0000025515843fb8 WdfTypeUsbInterface Object: 0x00000255158cbf40, Interface: 0x00000255158cbfb8 WdfTypeRequest Object: 0x00000255158d6e20, Interface: 0x00000255158d6e98 WdfTypeIoTarget Object: 0x000002551595be80, Interface: 0x000002551595bef8 WdfTypeIoTarget Object: 0x00000255159d1e80, Interface: 0x00000255159d1ef8 WdfTypeIoTarget Object: 0x0000025515a47e80, Interface: 0x0000025515a47ef8 WdfTypeRequest Object: 0x0000025515c07e20, Interface: 0x0000025515c07e98 WdfTypeMemoryObject Object: 0x0000025515e32f60, Interface: 0x0000025515e32fd8
I'm assuming an incorrect reference count on one of these objects is causing the error message displayed above to appear and preventing the ~CMyDevice() destructor from being called. But I'm at a bit of a loss to figure out which object from the list above is problematic? If anyone can suggest how to proceed I would appreciate it.
Answers
-
UMDF v1 is in maintenance mode since few releases of Windows now. You should consider upgrading to UMDF v2. As noted in the docs:
UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2. For more info, see Getting Started with UMDF.
That said, couple of suggestions:
- You can review this sample driver below that shows how to configure the continuous reader and also review the ref counts associated with the USB target pipe
https://github.com/microsoft/Windows-driver-samples/blob/6c1981b8504329521343ad00f32daa847fa6083a/usb/umdf_fx2/driver/Device.cpp - You can review the references associated with the IWDFUsbTargetPipe associated with the continuous reader (where you called ConfigureContinuousReader) using the debugger extension command !wudfext.wudfrefhist
- Edited by Shyamal Varma [MSFT] Tuesday, August 20, 2019 7:03 AM
- Marked as answer by Cymon Kilmer [MSFT]Moderator Friday, August 23, 2019 4:48 PM
- You can review this sample driver below that shows how to configure the continuous reader and also review the ref counts associated with the USB target pipe
All replies
-
UMDF v1 is in maintenance mode since few releases of Windows now. You should consider upgrading to UMDF v2. As noted in the docs:
UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2. For more info, see Getting Started with UMDF.
That said, couple of suggestions:
- You can review this sample driver below that shows how to configure the continuous reader and also review the ref counts associated with the USB target pipe
https://github.com/microsoft/Windows-driver-samples/blob/6c1981b8504329521343ad00f32daa847fa6083a/usb/umdf_fx2/driver/Device.cpp - You can review the references associated with the IWDFUsbTargetPipe associated with the continuous reader (where you called ConfigureContinuousReader) using the debugger extension command !wudfext.wudfrefhist
- Edited by Shyamal Varma [MSFT] Tuesday, August 20, 2019 7:03 AM
- Marked as answer by Cymon Kilmer [MSFT]Moderator Friday, August 23, 2019 4:48 PM
- You can review this sample driver below that shows how to configure the continuous reader and also review the ref counts associated with the USB target pipe
-