cristalink
Mon Aug 08 04:15:43 CDT 2005
> But the strange thing
There's nothing strange here. Your original approach is simply wrong. It
might work is some circumstances, but will crash the system in most other
cases.
--
http://www.cristalink.com
"WilliamX" <fantast_xue@hotmail.com.discuss> wrote in message
news:u64ugrjs9.fsf@hotmail.com.discuss...
> "cristalink" <cristalink@nospam.nospam> writes:
>
>> The problem is, the lower drivers overwrites
>> p_irp->Tail.Overlay.ListEntry,
>> thus screwing up your list. When you then remove p_irp from the list, you
>> are screwing up someone else's list.
>
> But the strange thing is that the crash only occured after unplug the
> power (when it is running). It runs O.K. and it is O.K. even when
> stopped regularly.
>
> And, though I have not checked, as reported back, it would not cause a
> crash in win2k and winxp+sp1.
>
> Maybe the situation which you refered to is a mine?
>
>>
>> The simplest alternative is to maintain a list of structures containing
>> pointers to IRPs. You'd need to allocate a structure per IRP, of course.
>> Another way could be using your IO_STACK_LOCATION as LIST_ENTRY. Sorry, I
>> don't have sample code at hand.
>>
>
> Yes, I have rounded this issue.
>
>>
>> --
>>
http://www.cristalink.com
>>
>>
>> "WilliamX" <fantast_xue@hotmail.com.discuss> wrote in message
>> news:uek95qcv4.fsf@hotmail.com.discuss...
>>> "cristalink" <cristalink@nospam.nospam> writes:
>>>
>>>> How do you know p_devobj is not using p_irp->Tail.Overlay.ListEntry
>>>> while
>>>
>>> I think it is using it. It would cause something? I inserted the
>>> Tail.Overlay.ListEntry to my list before call IoCallDriver, and
>>> removed it from my list after it returned from lower. Mybe I don't
>>> understand well how to use Tail.Overlay.ListEntry, please feel free to
>>> point out my mistakes.
>>>
>>>> you hold p_irp in your list? You must remove an IRP from the
>>>> Tail.Overlay
>>>> list before passing it to IoCallDriver. You should maintain the list by
>>>
>>> Could you so kindly to show me some code about how to do it?
>>>
>>>>
>>>> other means.
>>>> --
>>>>
http://www.cristalink.com
>>>>
>>>>
>>>> "WilliamX" <fantast_xue@hotmail.com.discuss> wrote in message
>>>> news:uiryhqgn0.fsf@hotmail.com.discuss...
>>>>>I made a bda driver for our usb box. It seems working well until I
>>>>> unplug the power wire when it running in winxp+sp2.(it saids that it
>>>>> did not crash in win2k or winxp+sp1, so strange.)
>>>>>
>>>>> In the read data routine, I insert the irp to a list and in the
>>>>> complete routine I remove it from the list. Like this:
>>>>> (I simply use the global variables.)
>>>>> Insert:
>>>>> --8<---------------cut here---------------start------------->8---
>>>>> KeAcquireSpinLock(&g_ks_pl, &g_old_pk_irql);
>>>>> InsertTailList(&g_irp_list, &p_irp->Tail.Overlay.ListEntry);
>>>>> KeReleaseSpinLock(&g_ks_pl, g_old_pk_irql);
>>>>>
>>>>> status = IoCallDriver(p_devobj, p_irp);
>>>>> --8<---------------cut here---------------end--------------->8---
>>>>> Removal:
>>>>> --8<---------------cut here---------------start------------->8---
>>>>> KeAcquireSpinLock(&g_ks_pl, &old_irql);
>>>>>
>>>>> if (IsListEmpty(&g_irp_list))
>>>>> {
>>>>> KeReleaseSpinLock(&g_ks_pl, old_irql);
>>>>> return FALSE;
>>>>> }
>>>>>
>>>>> RemoveHeadList(&g_irp_list);
>>>>> KeReleaseSpinLock(&g_ks_pl, old_irql);
>>>>> --8<---------------cut here---------------end--------------->8---
>>>>>
>>>>> After I unplug the power of the usb, winxp+sp2 would crash in
>>>>> usbport.sys. I commented out these codes, then unplug the power, no
>>>>> crash.
>>>>>
>>>>> I did not test the status of the irp, because I thought it was
>>>>> useless. I simply insert the irp to the queue and remove it after it
>>>>> completed.
>>>>>
>>>>> Could some one tell me what's wrong with my code?
>>>>> Advance thanks!
>>>>>