Issue with a Driver which isn't unloading

Hi all,

I am facing an issue with a Driver which isn’t unloading. This only happens
sometimes and it is driving me nuts. Anyway, here is a description of what I
have done so far and some questions.

This is for a USB device and the driver is based on WDF.

I have used an on access breakpoint to see the accesses to the reference
count (PointerCount). I have also added a break point in
the EvtDriverUnload callback function just to see the reference count when
that callback gets called. In the failing scenario I see that the ref count
is 2 and in the OK scenario the ref count is 1.
Also it should be mentioned that this happens when the device is surprise
removed. What I am doing is go in to S3 and resume after 10 seconds, when
the OS has resumed the device will sometimes be surprise removed.

An other thing that I did in the driver prior to noticing this failure to
unload was that I removed a call to Deinitialize the configuration.
According to a thread here on ntdev this was not supposed to be done when
the device was surprise removed. When this was done the driver could instead
hang and block the OS from going in to Sleep.

So my question.

Is there a way to figure out who has bumped the reference count and never
released it? I see a lot of nt!Pnp* in the stack each time the reference
count is accessed but this is not telling me much.
Could it be that the unload is failing because I removed the call to
deinitialize the configuration?

I would appreciate any sugestions on where to go from here on, if more
information is needed just tell me.

Thanks in advance.

Cheers
Faik

Could you force a bugcheck when the reference count > 2? Then run the driver with driver verifier and use windbg to locate the faulting source and then you would have your culprit?

Hi,

Enabling verifier didn’t help much. With verifier on the problem wasn’t
even reproducable. But thanks.

Cheers
/Faik

On 11/13/08, xxxxx@yahoo.co.uk wrote:
>
> Could you force a bugcheck when the reference count > 2? Then run the
> driver with driver verifier and use windbg to locate the faulting source and
> then you would have your culprit?
>
> —
> 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
>

What is the state of the devnode for that device?

On Fri, Nov 14, 2008 at 10:33 AM, Faik Riza wrote:

> Hi,
>
> Enabling verifier didn’t help much. With verifier on the problem wasn’t
> even reproducable. But thanks.
>
> Cheers
> /Faik
>
>
> On 11/13/08, xxxxx@yahoo.co.uk wrote:
>>
>> Could you force a bugcheck when the reference count > 2? Then run the
>> driver with driver verifier and use windbg to locate the faulting source and
>> then you would have your culprit?
>>
>> —
>> 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
>>
>
> — 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


Mark Roddy

Hi Mark,

A little late reply.

Dumped the device node with !devnode and here is the information. Note that
I only have the information for the problem driver here. The device it self
is a composite USB device and I am not showing the state for the other
drivers, this particular driver is one of the child devices loaded when
enumerated by a generic parrent driver. The other drivers load fine.

State = DeviceNodeInitialized
Previous State = DeviceNodeUninitialized
Problem = CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD

Thanks
/Faik

On 11/16/08, Mark Roddy wrote:
>
> What is the state of the devnode for that device?
>
> On Fri, Nov 14, 2008 at 10:33 AM, Faik Riza wrote:
>
>> Hi,
>>
>> Enabling verifier didn’t help much. With verifier on the problem wasn’t
>> even reproducable. But thanks.
>>
>> Cheers
>> /Faik
>>
>> On 11/13/08, xxxxx@yahoo.co.uk wrote:
>>>
>>> Could you force a bugcheck when the reference count > 2? Then run the
>>> driver with driver verifier and use windbg to locate the faulting source and
>>> then you would have your culprit?
>>>
>>> —
>>> 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
>>>
>>
>> — 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
>
>
>
>
> –
> Mark Roddy
> — 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