Newbie question: IRP with STATUS_PENDING in IoCompetion routine

Hi:

I am using IoAllocateIrp to create a TDI_ACCEPT IRP in my TDI client. The
connect event handler returns this IRP and the IRP’s completion routine is
called with the IRP’s status marked as pending (irp->PendingReturned ==
TRUE). As per the DDK, I call IoMarkIrpPending on the IRP and return with
STATUS_PENDING. The system crashes. Even if I don’t do that, the system
crashes.

When I pre-allocate and use TdiBuildInternalDeviceControlIrp the
TDI_ACCEPT IRP completes successfully. Here’s what I am doing now:

ConnectEventHandler
{
.
.
.
irp = IoAllocateIrp(deviceObject->StackSize, FALSE);
TdiBuildAccept(irp,…);
IoSetNextIrpStackLocation(irp);

}

IoAcceptComplete
{
//—update whatever is necessary
if(irp->PendingReturned)
{
IoMarkIrpPending(irp);
ntStatus = STATUS_PENDING;
}

return ntStatus;
}

My feeling is that I am missing out on something that I should do to the
IRP before returning it in the connectEventHandler. Can anyone advise?

KK

KK,
I believe you have a problem with your completion routine. You
check the pending returned flag and call IoMarkIrpPending that is all
fine. But returning STATUS_PENDING from completion routine, this does
not look right. Go through documentation and sample code. You should
return STATUS_SUCCESS, or any error value appropriate or
STATUS_MORE_PROCESSING_REQUIRED.

-Srin.

-----Original Message-----
From: Keshab Koch [mailto:xxxxx@india.nsc.com]
Sent: Monday, May 05, 2003 9:23 AM
To: NT Developers Interest List
Subject: [ntdev] Newbie question: IRP with STATUS_PENDING in IoCompetion
routine

Hi:

I am using IoAllocateIrp to create a TDI_ACCEPT IRP in my TDI client.
The
connect event handler returns this IRP and the IRP’s completion routine
is
called with the IRP’s status marked as pending (irp->PendingReturned ==
TRUE). As per the DDK, I call IoMarkIrpPending on the IRP and return
with
STATUS_PENDING. The system crashes. Even if I don’t do that, the system
crashes.

When I pre-allocate and use TdiBuildInternalDeviceControlIrp the
TDI_ACCEPT IRP completes successfully. Here’s what I am doing now:

ConnectEventHandler
{
.
.
.
irp = IoAllocateIrp(deviceObject->StackSize, FALSE);
TdiBuildAccept(irp,…);
IoSetNextIrpStackLocation(irp);

}

IoAcceptComplete
{
//—update whatever is necessary
if(irp->PendingReturned)
{
IoMarkIrpPending(irp);
ntStatus = STATUS_PENDING;
}

return ntStatus;
}

My feeling is that I am missing out on something that I should do to the
IRP before returning it in the connectEventHandler. Can anyone advise?

KK


You are currently subscribed to ntdev as: xxxxx@nai.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

  1. Find out the stack at the point of BSOD. Eg, in windbg, use the kb
    command.

  2. In an I/O completion routine, the returned status is either
    STATUS_MORE_PROCESSING_REQUIRED or anything else. In the “anything else”
    case, you must do:

if (pIrp->PendingReturned) IoMarkIrpPending(pIrp);

Your snippet would appear to be doing this, but without seeing the full
set of code, I cannot be sure. In any case, use a debugger to be sure
that when you’ve done the above, you’re really returning “anything else”
(eg, STATUS_PENDING).

Is the BSOD perchance IRP completed twice? If so, it’s very likely your
I/O completion code is bad.

  1. The fact that pre-allocating the IRP precludes BSOD is suspicious,
    because there is no inherent reason that should make a difference. I’d
    guess that when you pre-allocate, you’re also doing something else
    differently. Are you setting the I/O completion routine for the Accept
    IRP in both the pre-allocated and the IoAllocateIrp cases?

  2. I’ve done this sort of thing. Consult TDIClient.zip at
    http://home.mindspring.com/~antognini/drivers/.


If replying by e-mail, please remove “nospam.” from the address.

James Antognini

Return STATUS_MORE_PROCESSING_REQUIRED from the completion, and don’t
forget to call IoFreeIrp in it.

----- Original Message -----
From: “Keshab Koch”
To: “NT Developers Interest List”
Sent: Monday, May 05, 2003 8:22 PM
Subject: [ntdev] Newbie question: IRP with STATUS_PENDING in
IoCompetion routine

> Hi:
>
> I am using IoAllocateIrp to create a TDI_ACCEPT IRP in my TDI
client. The
> connect event handler returns this IRP and the IRP’s completion
routine is
> called with the IRP’s status marked as pending (irp->PendingReturned
==
> TRUE). As per the DDK, I call IoMarkIrpPending on the IRP and return
with
> STATUS_PENDING. The system crashes. Even if I don’t do that, the
system
> crashes.
>
> When I pre-allocate and use TdiBuildInternalDeviceControlIrp the
> TDI_ACCEPT IRP completes successfully. Here’s what I am doing now:
>
> ConnectEventHandler
> {
> .
> .
> .
> irp = IoAllocateIrp(deviceObject->StackSize, FALSE);
> TdiBuildAccept(irp,…);
> IoSetNextIrpStackLocation(irp);
> …
> }
>
> IoAcceptComplete
> {
> //—update whatever is necessary
> if(irp->PendingReturned)
> {
> IoMarkIrpPending(irp);
> ntStatus = STATUS_PENDING;
> }
> …
> return ntStatus;
> }
>
> My feeling is that I am missing out on something that I should do to
the
> IRP before returning it in the connectEventHandler. Can anyone
advise?
>
> KK
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

Hi Maxim:

Thanks for the tip. It worked!

KK

Return STATUS_MORE_PROCESSING_REQUIRED from the completion, and don’t
forget to call IoFreeIrp in it.

----- Original Message -----
From: “Keshab Koch”
> To: “NT Developers Interest List”
> Sent: Monday, May 05, 2003 8:22 PM
> Subject: [ntdev] Newbie question: IRP with STATUS_PENDING in
> IoCompetion routine
>
>
> > Hi:
> >
> > I am using IoAllocateIrp to create a TDI_ACCEPT IRP in my TDI
> client. The
> > connect event handler returns this IRP and the IRP’s completion
> routine is
> > called with the IRP’s status marked as pending (irp->PendingReturned
> ==
> > TRUE). As per the DDK, I call IoMarkIrpPending on the IRP and return
> with
> > STATUS_PENDING. The system crashes. Even if I don’t do that, the
> system
> > crashes.
> >
> > When I pre-allocate and use TdiBuildInternalDeviceControlIrp the
> > TDI_ACCEPT IRP completes successfully. Here’s what I am doing now:
> >
> > ConnectEventHandler
> > {
> > .
> > .
> > .
> > irp = IoAllocateIrp(deviceObject->StackSize, FALSE);
> > TdiBuildAccept(irp,…);
> > IoSetNextIrpStackLocation(irp);
> > …
> > }
> >
> > IoAcceptComplete
> > {
> > //—update whatever is necessary
> > if(irp->PendingReturned)
> > {
> > IoMarkIrpPending(irp);
> > ntStatus = STATUS_PENDING;
> > }
> > …
> > return ntStatus;
> > }
> >
> > My feeling is that I am missing out on something that I should do to
> the
> > IRP before returning it in the connectEventHandler. Can anyone
> advise?
> >
> > KK
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com