system crash when serial driver calls IoCancelIrp

Dear All,
I have a pointer driver for Serial port. The Port is enumerated by
Serial to USB Convertor driver. Now i post a Read Irp, after registering a
Completion Routine to the Sertousb convertor driver.

When there’s no data coming from the device, i surprise remove the
sertousb cable. Now the system crashes. When i see the stack, the top
function is IoCancelIrp called by the sertousb driver.

I read in ddk documentation that when a driver which doesn’t own an
Irp cancels the Irp, the results are unpredictable. But the cancelling of
the Irp (not owned by it) by sertousb driver seems to be logically fine.

Now what care should i take in my driver so that IoCancelIrp call by
the sertousb driver doesn’t crash the system?

Thanks
Sesha.
**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

  1. turn on driver verifier for your driver and probably everyone else in
    the usb stack.

  2. see (1) :slight_smile:

It is possible that usbser has a bug in its cancel processing, but it is
more likely that you have not implemented your part of cancel processing
correctly.

You should provide that actual details of the crashdump stack, rather
than your interpretation of the crashdump stack.

=====================
Mark Roddy
Windows XP/2000/NT Consultant, Microsoft MVP
Hollis Technology Solutions 603-321-1032
www.hollistech.com
xxxxx@hollistech.com
For Windows Device Driver Training: see www.azius.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Seshagiri_Babu
Sent: Thursday, August 01, 2002 6:21 AM
To: NT Developers Interest List
Subject: [ntdev] system crash when serial driver calls IoCancelIrp

Dear All,
I have a pointer driver for Serial port. The Port is
enumerated by Serial to USB Convertor driver. Now i post a
Read Irp, after registering a Completion Routine to the
Sertousb convertor driver.

When there’s no data coming from the device, i surprise
remove the sertousb cable. Now the system crashes. When i see
the stack, the top function is IoCancelIrp called by the
sertousb driver.

I read in ddk documentation that when a driver which
doesn’t own an Irp cancels the Irp, the results are
unpredictable. But the cancelling of the Irp (not owned by
it) by sertousb driver seems to be logically fine.

Now what care should i take in my driver so that
IoCancelIrp call by the sertousb driver doesn’t crash the system?

Thanks
Sesha.
**************************************************************
************
This email (including any attachments) is intended for the
sole use of the intended recipient/s and may contain material
that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any
review or reliance by others or copying or distribution or
forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient,
please contact the sender by email and delete all copies;
your cooperation in this regard is appreciated.
**************************************************************
************


You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
%%email.unsub%%

Hi Giri,
What ever crash has happened seems logical 'coz you have allocated IRP
and have passed to the Ser-USB Converter.Now it is handling PNP Irp’s and on
receiving IRP_MN_REMOVE it is probably checking the pending IRP’s with it
and trying to cancel them all…what you can do is handle PNP Irp’s in ur
driver and cancel the IRP urself,in which case the IO Manager would free the
IRP and the Serial-USB Converter driver doesn’t again call IoCancelIrp after
checking for NULL condition.

This is what I thought logically,try it.

Regs,
sai

-----Original Message-----
From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
Sent: Thursday, August 01, 2002 3:51 PM
To: NT Developers Interest List
Subject: [ntdev] system crash when serial driver calls IoCancelIrp

Dear All,
I have a pointer driver for Serial port. The Port is enumerated by
Serial to USB Convertor driver. Now i post a Read Irp, after registering a
Completion Routine to the Sertousb convertor driver.

When there’s no data coming from the device, i surprise remove the
sertousb cable. Now the system crashes. When i see the stack, the top
function is IoCancelIrp called by the sertousb driver.

I read in ddk documentation that when a driver which doesn’t own an
Irp cancels the Irp, the results are unpredictable. But the cancelling of
the Irp (not owned by it) by sertousb driver seems to be logically fine.

Now what care should i take in my driver so that IoCancelIrp call by
the sertousb driver doesn’t crash the system?

Thanks
Sesha.
**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************


You are currently subscribed to ntdev as: xxxxx@ssdi.sharp.co.in
To unsubscribe send a blank email to %%email.unsub%%

Let me explain the problem clearly.

Say the serial to usb converter driver is sertousb.sys. It exposes a
new COM port on my PC whenever the cable is plugged in. Let us name my
driver as mydriver.sys.

Now mydriver.sys keeps only one Read Irp posted to sertousb.sys all
the time. ie, posts a new read irp as soon as it gets completed.

Now when i surprise remove the cable, sertousb.sys gets
IRP_MN_SURPRISE_REMOVAL pnp Irp. In the handler, sertousb.sys tries to
cancel all the pending IRP’s.

It is at this stage that the crash is occuring on a call to
IoCancelIrp by sertousb.sys.

Now i would like to know what care i should take in mydriver.sys so
that when sertousb.sys calls IoCancelIrp on the Irp allocated by
mydriver.sys will not crash the system.

thanks
Sesha.


From: Sai Prasad P[SMTP:xxxxx@ssdi.sharp.co.in]
Reply To: NT Developers Interest List
Sent: 2002"N8OEZ2"? 12:29
To: NT Developers Interest List
Subject: [ntdev] RE: system crash when serial driver calls
IoCancelIrp

Hi Giri,
What ever crash has happened seems logical 'coz you have allocated IRP
and have passed to the Ser-USB Converter.Now it is handling PNP Irp’s and
on
receiving IRP_MN_REMOVE it is probably checking the pending IRP’s with it
and trying to cancel them all…what you can do is handle PNP Irp’s in ur
driver and cancel the IRP urself,in which case the IO Manager would free
the
IRP and the Serial-USB Converter driver doesn’t again call IoCancelIrp
after
checking for NULL condition.

This is what I thought logically,try it.

Regs,
sai

-----Original Message-----
From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
Sent: Thursday, August 01, 2002 3:51 PM
To: NT Developers Interest List
Subject: [ntdev] system crash when serial driver calls IoCancelIrp

Dear All,
I have a pointer driver for Serial port. The Port is enumerated by
Serial to USB Convertor driver. Now i post a Read Irp, after registering a
Completion Routine to the Sertousb convertor driver.

When there’s no data coming from the device, i surprise remove the
sertousb cable. Now the system crashes. When i see the stack, the top
function is IoCancelIrp called by the sertousb driver.

I read in ddk documentation that when a driver which doesn’t own an
Irp cancels the Irp, the results are unpredictable. But the cancelling of
the Irp (not owned by it) by sertousb driver seems to be logically fine.

Now what care should i take in my driver so that IoCancelIrp call by
the sertousb driver doesn’t crash the system?

Thanks
Sesha.
**************************************************************************

This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
or
distribution or forwarding of any or all of the contents in this message
is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************


You are currently subscribed to ntdev as: xxxxx@ssdi.sharp.co.in
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@satyam.com
To unsubscribe send a blank email to %%email.unsub%%

**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

Sertousb can’t cancel the IRP…I will try to explain my
understanding…your driver(Mydriver.sys) has built an IRP,some other
driver(sertousb.sys) can’t cancel the IRP because it is not the owner…so
you try to cancel the irp you have allocated by yourself…i.e.,you might
register for the plugplay notification on guid of sertousb and on
removal,cancel the IRP you had allocated.

Regs,
sai

-----Original Message-----
From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
Sent: Friday, August 02, 2002 12:24 PM
To: NT Developers Interest List
Subject: [ntdev] RE: system crash when serial driver calls IoCancelIrp

Let me explain the problem clearly.

Say the serial to usb converter driver is sertousb.sys. It exposes a
new COM port on my PC whenever the cable is plugged in. Let us name my
driver as mydriver.sys.

Now mydriver.sys keeps only one Read Irp posted to sertousb.sys all
the time. ie, posts a new read irp as soon as it gets completed.

Now when i surprise remove the cable, sertousb.sys gets
IRP_MN_SURPRISE_REMOVAL pnp Irp. In the handler, sertousb.sys tries to
cancel all the pending IRP’s.

It is at this stage that the crash is occuring on a call to
IoCancelIrp by sertousb.sys.

Now i would like to know what care i should take in mydriver.sys so
that when sertousb.sys calls IoCancelIrp on the Irp allocated by
mydriver.sys will not crash the system.

thanks
Sesha.


From: Sai Prasad P[SMTP:xxxxx@ssdi.sharp.co.in]
Reply To: NT Developers Interest List
Sent: 2002"N8OEZ2"? 12:29
To: NT Developers Interest List
Subject: [ntdev] RE: system crash when serial driver calls
IoCancelIrp

Hi Giri,
What ever crash has happened seems logical 'coz you have allocated IRP
and have passed to the Ser-USB Converter.Now it is handling PNP Irp’s and
on
receiving IRP_MN_REMOVE it is probably checking the pending IRP’s with it
and trying to cancel them all…what you can do is handle PNP Irp’s in ur
driver and cancel the IRP urself,in which case the IO Manager would free
the
IRP and the Serial-USB Converter driver doesn’t again call IoCancelIrp
after
checking for NULL condition.

This is what I thought logically,try it.

Regs,
sai

-----Original Message-----
From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
Sent: Thursday, August 01, 2002 3:51 PM
To: NT Developers Interest List
Subject: [ntdev] system crash when serial driver calls IoCancelIrp

Dear All,
I have a pointer driver for Serial port. The Port is enumerated by
Serial to USB Convertor driver. Now i post a Read Irp, after registering a
Completion Routine to the Sertousb convertor driver.

When there’s no data coming from the device, i surprise remove the
sertousb cable. Now the system crashes. When i see the stack, the top
function is IoCancelIrp called by the sertousb driver.

I read in ddk documentation that when a driver which doesn’t own an
Irp cancels the Irp, the results are unpredictable. But the cancelling of
the Irp (not owned by it) by sertousb driver seems to be logically fine.

Now what care should i take in my driver so that IoCancelIrp call by
the sertousb driver doesn’t crash the system?

Thanks
Sesha.
**************************************************************************

This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
or
distribution or forwarding of any or all of the contents in this message
is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************


You are currently subscribed to ntdev as: xxxxx@ssdi.sharp.co.in
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@satyam.com
To unsubscribe send a blank email to %%email.unsub%%

**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************


You are currently subscribed to ntdev as: xxxxx@ssdi.sharp.co.in
To unsubscribe send a blank email to %%email.unsub%%

sertousb.sys can cancel the Irp even if its’ not the owner. Its
mydriver.sys’s cancellation routine that will be called when the Irp is
cancelled.

IRP_MN_SURPRISE_REMOVAL first goes to sertousb.sys. Now this guy can
take two course of actions:

  1. Call IoSetDeviceInterface(FALSE) and then Cancelling all Irp’s if they
    are not yet cancelled.
  2. Cancel all pending Irp’s and then cal IoSetDeviceInterface(FALSE);

If you can refer to serial driver sample of DDK, sequence 2 is happening so
there is NO chance that i’ll be getting notification before sertousb.sys
cancels all pending Irp’s.

src\kernel\serial\pnp.c Ref: lines 1178 and 1211

And before mydriver.sys could get the removal notification, the crash is
occuring at sertousb->IoCancelIrp call.


From: Sai Prasad P[SMTP:xxxxx@ssdi.sharp.co.in]
Reply To: NT Developers Interest List
Sent: 2002"N8OEZ2"? 13:53
To: NT Developers Interest List
Subject: [ntdev] RE: system crash when serial driver calls
IoCancelIrp

Sertousb can’t cancel the IRP…I will try to explain my
understanding…your driver(Mydriver.sys) has built an IRP,some other
driver(sertousb.sys) can’t cancel the IRP because it is not the
owner…so
you try to cancel the irp you have allocated by yourself…i.e.,you might
register for the plugplay notification on guid of sertousb and on
removal,cancel the IRP you had allocated.

Regs,
sai

-----Original Message-----
From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
Sent: Friday, August 02, 2002 12:24 PM
To: NT Developers Interest List
Subject: [ntdev] RE: system crash when serial driver calls IoCancelIrp

Let me explain the problem clearly.

Say the serial to usb converter driver is sertousb.sys. It exposes a
new COM port on my PC whenever the cable is plugged in. Let us name my
driver as mydriver.sys.

Now mydriver.sys keeps only one Read Irp posted to sertousb.sys all
the time. ie, posts a new read irp as soon as it gets completed.

Now when i surprise remove the cable, sertousb.sys gets
IRP_MN_SURPRISE_REMOVAL pnp Irp. In the handler, sertousb.sys tries to
cancel all the pending IRP’s.

It is at this stage that the crash is occuring on a call to
IoCancelIrp by sertousb.sys.

Now i would like to know what care i should take in mydriver.sys so
that when sertousb.sys calls IoCancelIrp on the Irp allocated by
mydriver.sys will not crash the system.

thanks
Sesha.

> ----------
> From: Sai Prasad P[SMTP:xxxxx@ssdi.sharp.co.in]
> Reply To: NT Developers Interest List
> Sent: 2002"N8OEZ2"? 12:29
> To: NT Developers Interest List
> Subject: [ntdev] RE: system crash when serial driver calls
> IoCancelIrp
>
> Hi Giri,
> What ever crash has happened seems logical 'coz you have allocated
IRP
> and have passed to the Ser-USB Converter.Now it is handling PNP Irp’s
and
> on
> receiving IRP_MN_REMOVE it is probably checking the pending IRP’s with
it
> and trying to cancel them all…what you can do is handle PNP Irp’s in
ur
> driver and cancel the IRP urself,in which case the IO Manager would free
> the
> IRP and the Serial-USB Converter driver doesn’t again call IoCancelIrp
> after
> checking for NULL condition.
>
> This is what I thought logically,try it.
>
> Regs,
> sai
>
> -----Original Message-----
> From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
> Sent: Thursday, August 01, 2002 3:51 PM
> To: NT Developers Interest List
> Subject: [ntdev] system crash when serial driver calls IoCancelIrp
>
>
> Dear All,
> I have a pointer driver for Serial port. The Port is enumerated by
> Serial to USB Convertor driver. Now i post a Read Irp, after registering
a
> Completion Routine to the Sertousb convertor driver.
>
> When there’s no data coming from the device, i surprise remove the
> sertousb cable. Now the system crashes. When i see the stack, the top
> function is IoCancelIrp called by the sertousb driver.
>
> I read in ddk documentation that when a driver which doesn’t own an
> Irp cancels the Irp, the results are unpredictable. But the cancelling
of
> the Irp (not owned by it) by sertousb driver seems to be logically fine.

>
> Now what care should i take in my driver so that IoCancelIrp call by
> the sertousb driver doesn’t crash the system?
>
> Thanks
> Sesha.
>
**************************************************************************
>
> This email (including any attachments) is intended for the sole use of
the
> intended recipient/s and may contain material that is CONFIDENTIAL AND
> PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
> or
> distribution or forwarding of any or all of the contents in this message
> is
> STRICTLY PROHIBITED. If you are not the intended recipient, please
contact
> the sender by email and delete all copies; your cooperation in this
regard
> is appreciated.
>
**************************************************************************
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@ssdi.sharp.co.in
> To unsubscribe send a blank email to %%email.unsub%%
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@satyam.com
> To unsubscribe send a blank email to %%email.unsub%%
>
**************************************************************************

This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
or
distribution or forwarding of any or all of the contents in this message
is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************


You are currently subscribed to ntdev as: xxxxx@ssdi.sharp.co.in
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@satyam.com
To unsubscribe send a blank email to %%email.unsub%%

**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

Dear All,
These are few lines from the documentation of IoCancelIrp from DDK.
If a driver that does not own the IRP calls IoCancelIrp, the results are
unpredictable. The IRP might be completed with a successful status even
though its cancel bit was set.
But i see its’ necessary for drivers like Serial to cancel all
pending Irp’s when they recieve IRP_MN_SURPRISE_REMOVAL or
IRP_MN_REOVE_DEVICE. What does serial.sys do to take avoid these
unpredicatable results?
Actually we have a driver for pnp COM port and when the cable is
unplugged, the driver is crashing at IoCancelIrp call. This is a third party
driver and its getting difficult to know whether the bug is in this driver
or in our driver which passes IRP_MJ_READ requests to it.
Thanks in Advance for any help
Sesha.
**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

In the serial.sys case, it is queueing the IRPs that you would be
calling IoCancelIrp on. So given that, when serial wants to complete
these IRPs with an error, it just dequeues the IRP safely (ie making
sure it can dequeue and remove the cancel routine) and then calls
IoCompleteRequest on the IRP; there is no need to call IoCancelIrp on
the IRP it already owns.

D

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
Sent: Monday, August 05, 2002 10:50 PM
To: NT Developers Interest List
Subject: [ntdev] IoCancelIrp

Dear All,
These are few lines from the documentation of IoCancelIrp from
DDK.
If a driver that does not own the IRP calls IoCancelIrp, the results are
unpredictable. The IRP might be completed with a successful status even
though its cancel bit was set.
But i see its’ necessary for drivers like Serial to cancel all
pending Irp’s when they recieve IRP_MN_SURPRISE_REMOVAL or
IRP_MN_REOVE_DEVICE. What does serial.sys do to take avoid these
unpredicatable results?
Actually we have a driver for pnp COM port and when the cable is
unplugged, the driver is crashing at IoCancelIrp call. This is a third
party
driver and its getting difficult to know whether the bug is in this
driver
or in our driver which passes IRP_MJ_READ requests to it.
Thanks in Advance for any help
Sesha.
************************************************************************
**
This email (including any attachments) is intended for the sole use of
the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
or
distribution or forwarding of any or all of the contents in this message
is
STRICTLY PROHIBITED. If you are not the intended recipient, please
contact
the sender by email and delete all copies; your cooperation in this
regard
is appreciated.
************************************************************************
**


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%

Thanks Doron. But my driver calling IoCancelIrp is just one case…

Let me be more clear. Actually the Serial Port we are using is that of a COM
Port exposed by Serial to usb Convertor when it is plugged in to the host
pc.

Lets name this serial driver myserial.sys. MS’s Serial.sys doesn’t have
anything to do with the COM Port enumerated by myserial.sys. And i have one
Pointer Port driver mypointer.sys.

Now the job of mypointer.sys is to read data from pnp serial port
enumerated by myserial.sys. So it keeps posting IRP_MJ_READ’s to
myserial.sys. Now when both drivers are on, i unplug the Serial to usb
convertor cable.

Now myserial.sys recieves IRP_MN_SURPRISE_REMOVAL. So it starts
cancelling (this is the case i was trying to tell, IoCancelIrp not by the
owner of the Irp) all the pending IRP’s including the IRP_MJ_READ Irp posted
by mypointer.sys.

At present myserial.sys is crashing the host pc on a call to
IoCancelIrp. Now how do i find if the bug is in myserial.sys or
mypointer.sys?


From: Doron Holan[SMTP:xxxxx@windows.microsoft.com]
Reply To: NT Developers Interest List
Sent: 2002"N8OEZ6"? 11:31
To: NT Developers Interest List
Subject: [ntdev] RE: IoCancelIrp

In the serial.sys case, it is queueing the IRPs that you would be
calling IoCancelIrp on. So given that, when serial wants to complete
these IRPs with an error, it just dequeues the IRP safely (ie making
sure it can dequeue and remove the cancel routine) and then calls
IoCompleteRequest on the IRP; there is no need to call IoCancelIrp on
the IRP it already owns.

D

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
Sent: Monday, August 05, 2002 10:50 PM
To: NT Developers Interest List
Subject: [ntdev] IoCancelIrp

Dear All,
These are few lines from the documentation of IoCancelIrp from
DDK.
If a driver that does not own the IRP calls IoCancelIrp, the results are
unpredictable. The IRP might be completed with a successful status even
though its cancel bit was set.
But i see its’ necessary for drivers like Serial to cancel all
pending Irp’s when they recieve IRP_MN_SURPRISE_REMOVAL or
IRP_MN_REOVE_DEVICE. What does serial.sys do to take avoid these
unpredicatable results?
Actually we have a driver for pnp COM port and when the cable is
unplugged, the driver is crashing at IoCancelIrp call. This is a third
party
driver and its getting difficult to know whether the bug is in this
driver
or in our driver which passes IRP_MJ_READ requests to it.
Thanks in Advance for any help
Sesha.
************************************************************************
**
This email (including any attachments) is intended for the sole use of
the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
or
distribution or forwarding of any or all of the contents in this message
is
STRICTLY PROHIBITED. If you are not the intended recipient, please
contact
the sender by email and delete all copies; your cooperation in this
regard
is appreciated.
************************************************************************
**


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@satyam.com
To unsubscribe send a blank email to %%email.unsub%%

**************************************************************************
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************

How about showing us the bugcheck code with parameters and a callstack when
your machine crashes? Its hard to know why something is failing without
info.


Bill McKenzie
Windows DDK MVP
OSR - Windows System Software Development, Training, and Consulting

“Seshagiri_Babu” wrote in message
news:xxxxx@ntdev…
>
> Dear All,
> These are few lines from the documentation of IoCancelIrp from DDK.
> If a driver that does not own the IRP calls IoCancelIrp, the results are
> unpredictable. The IRP might be completed with a successful status even
> though its cancel bit was set.
> But i see its’ necessary for drivers like Serial to cancel all
> pending Irp’s when they recieve IRP_MN_SURPRISE_REMOVAL or
> IRP_MN_REOVE_DEVICE. What does serial.sys do to take avoid these
> unpredicatable results?
> Actually we have a driver for pnp COM port and when the cable is
> unplugged, the driver is crashing at IoCancelIrp call. This is a third
party
> driver and its getting difficult to know whether the bug is in this driver
> or in our driver which passes IRP_MJ_READ requests to it.
> Thanks in Advance for any help
> Sesha.
>
> This email (including any attachments) is intended for the sole use of the
> intended recipient/s and may contain material that is CONFIDENTIAL AND
> PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
or
> distribution or forwarding of any or all of the contents in this message
is
> STRICTLY PROHIBITED. If you are not the intended recipient, please contact
> the sender by email and delete all copies; your cooperation in this regard
> is appreciated.
>

>
>
>

Why not hold onto the original IRP, and allocate a new IRP that you pass to the driver below?
Then you are calling IoCancelIrp on an IRP you own.

This is still tricky, in that the context you are calling IoCancelIrp is different than the context
that the IRP might be completing in, and you shouldn’t hold any locks when calling IoCancelIrp.
Therefore you must use another mechanism (e.g., reference counts) to ensure that you don’t
call IoCancelIrp on an IRP you have just deallocated.

-DH
PS. The problem you are having may be that you are calling IoCancelIrp on an IRP that
has just completed.

“Seshagiri_Babu” wrote in message news:xxxxx@ntdev…

Thanks Doron. But my driver calling IoCancelIrp is just one case…

Let me be more clear. Actually the Serial Port we are using is that of a COM
Port exposed by Serial to usb Convertor when it is plugged in to the host
pc.

Lets name this serial driver myserial.sys. MS’s Serial.sys doesn’t have
anything to do with the COM Port enumerated by myserial.sys. And i have one
Pointer Port driver mypointer.sys.

Now the job of mypointer.sys is to read data from pnp serial port
enumerated by myserial.sys. So it keeps posting IRP_MJ_READ’s to
myserial.sys. Now when both drivers are on, i unplug the Serial to usb
convertor cable.

Now myserial.sys recieves IRP_MN_SURPRISE_REMOVAL. So it starts
cancelling (this is the case i was trying to tell, IoCancelIrp not by the
owner of the Irp) all the pending IRP’s including the IRP_MJ_READ Irp posted
by mypointer.sys.

At present myserial.sys is crashing the host pc on a call to
IoCancelIrp. Now how do i find if the bug is in myserial.sys or
mypointer.sys?

> ----------
> From: Doron Holan[SMTP:xxxxx@windows.microsoft.com]
> Reply To: NT Developers Interest List
> Sent: 2002"N8OEZ6"ú 11:31
> To: NT Developers Interest List
> Subject: [ntdev] RE: IoCancelIrp
>
> In the serial.sys case, it is queueing the IRPs that you would be
> calling IoCancelIrp on. So given that, when serial wants to complete
> these IRPs with an error, it just dequeues the IRP safely (ie making
> sure it can dequeue and remove the cancel routine) and then calls
> IoCompleteRequest on the IRP; there is no need to call IoCancelIrp on
> the IRP it already owns.
>
> D
>
> This posting is provided “AS IS” with no warranties, and confers no
> rights.
>
> -----Original Message-----
> From: Seshagiri_Babu [mailto:xxxxx@Satyam.com]
> Sent: Monday, August 05, 2002 10:50 PM
> To: NT Developers Interest List
> Subject: [ntdev] IoCancelIrp
>
> Dear All,
> These are few lines from the documentation of IoCancelIrp from
> DDK.
> If a driver that does not own the IRP calls IoCancelIrp, the results are
> unpredictable. The IRP might be completed with a successful status even
> though its cancel bit was set.
> But i see its’ necessary for drivers like Serial to cancel all
> pending Irp’s when they recieve IRP_MN_SURPRISE_REMOVAL or
> IRP_MN_REOVE_DEVICE. What does serial.sys do to take avoid these
> unpredicatable results?
> Actually we have a driver for pnp COM port and when the cable is
> unplugged, the driver is crashing at IoCancelIrp call. This is a third
> party
> driver and its getting difficult to know whether the bug is in this
> driver
> or in our driver which passes IRP_MJ_READ requests to it.
> Thanks in Advance for any help
> Sesha.
>
>

> This email (including any attachments) is intended for the sole use of
> the
> intended recipient/s and may contain material that is CONFIDENTIAL AND
> PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying
> or
> distribution or forwarding of any or all of the contents in this message
> is
> STRICTLY PROHIBITED. If you are not the intended recipient, please
> contact
> the sender by email and delete all copies; your cooperation in this
> regard
> is appreciated.
>
>

>
>
> —
> You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
> To unsubscribe send a blank email to %%email.unsub%%
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@satyam.com
> To unsubscribe send a blank email to %%email.unsub%%
>

This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
********