hang when calling WdfObjectDelete(WdfIoQueueGetDevice(Queue));

I am calling this function in response to a custom IOCTL code that is
sent by my user mode app when it wants to shutdown my non-pnp driver. In
the debugger the message:
“Thread 0x821B3588 is waiting for WDFQUEUE 7E0AB7D8 to be deleted”
repeats endlessly every 30 seconds.

–Jeremy

H’mm, that’s a good one-line deadlock!

The queue can’t go away because you are in one of its callbacks- after all, we can’t know you haven’t got more IRPS to process, and that state would be maintained in the queue. The device can’t go away, because the queue can’t go away. The underlying device can’t go away (completely) anyway- you’ve got a handle open to it, or you couldn’t even be processing this IOCTL.

I’d suggest completing this request after queuing a work item to do the deletion (parent the item to the driver).

Or have a single control object which is where I/O controls to create or
delete the other objects would be sent to. This would also allow you to
provide a different ACL for the control object vs. the other objects.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bob Kjelgaard
Sent: Friday, September 15, 2006 8:39 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] hang when calling
WdfObjectDelete(WdfIoQueueGetDevice(Queue));

H’mm, that’s a good one-line deadlock!

The queue can’t go away because you are in one of its callbacks- after
all, we can’t know you haven’t got more IRPS to process, and that state
would be maintained in the queue. The device can’t go away, because the
queue can’t go away. The underlying device can’t go away (completely)
anyway- you’ve got a handle open to it, or you couldn’t even be
processing this IOCTL.

I’d suggest completing this request after queuing a work item to do the
deletion (parent the item to the driver).


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Is anyone familiar with the nonpnp sample? I copied its method of
sending an ioctl (IOCTL_NONPNP_METHOD_DELETE_DEVICE) to delete the
device. What is it about that driver that makes it work? While my driver
has evolved quite a bit, it started as the nonpnp sample.

Peter suggested that I use my control object to delete the device- but
then how do I delete the control object?

Thanks,
–Jeremy

Bob Kjelgaard wrote:

H’mm, that’s a good one-line deadlock!

The queue can’t go away because you are in one of its callbacks- after all, we can’t know you haven’t got more IRPS to process, and that state would be maintained in the queue. The device can’t go away, because the queue can’t go away. The underlying device can’t go away (completely) anyway- you’ve got a handle open to it, or you couldn’t even be processing this IOCTL.

I’d suggest completing this request after queuing a work item to do the deletion (parent the item to the driver).

Just a thought…You delete the Control Device in your unload routine. Your
control object wont be stacked on other device objects. ITs exclusively
yours. Make sure your application releases handle on the control device.

-Giri.

On 9/16/06, Jeremy Chaney wrote:
>
> Is anyone familiar with the nonpnp sample? I copied its method of
> sending an ioctl (IOCTL_NONPNP_METHOD_DELETE_DEVICE) to delete the
> device. What is it about that driver that makes it work? While my driver
> has evolved quite a bit, it started as the nonpnp sample.
>
> Peter suggested that I use my control object to delete the device- but
> then how do I delete the control object?
>
> Thanks,
> --Jeremy
>
>
> Bob Kjelgaard wrote:
> > H’mm, that’s a good one-line deadlock!
> >
> > The queue can’t go away because you are in one of its callbacks- after
> all, we can’t know you haven’t got more IRPS to process, and that state
> would be maintained in the queue. The device can’t go away, because the
> queue can’t go away. The underlying device can’t go away (completely)
> anyway- you’ve got a handle open to it, or you couldn’t even be processing
> this IOCTL.
> >
> > I’d suggest completing this request after queuing a work item to do the
> deletion (parent the item to the driver).
> >
> >
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

That IOCTL code doesn’t exist anywhere in my entire RC1 WDK source tree. Are you sure that isn’t one of your additions?

The nonpnp code I see has ioctls named for the various buffered/non-buffered methods (MEHOD_BUFFERED, METHOD_NEITHER, etc) only- it illustrates their handling. I don’t see a WdfObjectDelete call anywhere in the sample, either.

Normally you just delete the device in your unload routine in a non-Pnp driver. I believe KMDF will just do that for you (but I haven’t done it myself, so I’m not 100% on that).

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jeremy Chaney
Sent: Friday, September 15, 2006 11:56 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] hang when calling WdfObjectDelete(WdfIoQueueGetDevice(Queue));

Is anyone familiar with the nonpnp sample? I copied its method of
sending an ioctl (IOCTL_NONPNP_METHOD_DELETE_DEVICE) to delete the
device. What is it about that driver that makes it work? While my driver
has evolved quite a bit, it started as the nonpnp sample.

Peter suggested that I use my control object to delete the device- but
then how do I delete the control object?

Thanks,
–Jeremy

Bob Kjelgaard wrote:

H’mm, that’s a good one-line deadlock!

The queue can’t go away because you are in one of its callbacks- after all, we can’t know you haven’t got more IRPS to process, and that state would be maintained in the queue. The device can’t go away, because the queue can’t go away. The underlying device can’t go away (completely) anyway- you’ve got a handle open to it, or you couldn’t even be processing this IOCTL.

I’d suggest completing this request after queuing a work item to do the deletion (parent the item to the driver).


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

you don’t need to delete the control device, it will not prevent your
driver from unloading (since it is an NT4 style driver) and will be
automatically deleted by KMDF if you don’t delete it on unload.

As for the delete device IOCTL, that was test code I accidentally
checked in and should not have been released :(. Sorry.

d

– I can spell, I just can’t type.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jeremy Chaney
Sent: Friday, September 15, 2006 11:56 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] hang when calling
WdfObjectDelete(WdfIoQueueGetDevice(Queue));

Is anyone familiar with the nonpnp sample? I copied its method of
sending an ioctl (IOCTL_NONPNP_METHOD_DELETE_DEVICE) to delete the
device. What is it about that driver that makes it work? While my driver
has evolved quite a bit, it started as the nonpnp sample.

Peter suggested that I use my control object to delete the device- but
then how do I delete the control object?

Thanks,
–Jeremy

Bob Kjelgaard wrote:

H’mm, that’s a good one-line deadlock!

The queue can’t go away because you are in one of its callbacks- after
all, we can’t know you haven’t got more IRPS to process, and that state
would be maintained in the queue. The device can’t go away, because the
queue can’t go away. The underlying device can’t go away (completely)
anyway- you’ve got a handle open to it, or you couldn’t even be
processing this IOCTL.

I’d suggest completing this request after queuing a work item to do
the deletion (parent the item to the driver).


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I’ll just add there are some chagrined QA folks noticing we let this get past us, and we’re sorry about it as well…

The fact that I’m getting personal tech support directly from the author
more than makes up for the mistake. I’ll fix my code as suggested by
everyone.

For Bob, I’m building with KMDF 1.1, not the WDK (that is why you didn’t
see the IOCTL in your source). I tried to build with the WDK, but I’m
getting a build error (I posted the question as its own thread) that I
can’t figure out.

Thanks,
–Jeremy

Bob Kjelgaard wrote:

I’ll just add there are some chagrined QA folks noticing we let this get past us, and we’re sorry about it as well…