Hi Matt,
These suggestions make a lot of sense for a starter like me .
Thanks
-anurag
-----Original Message-----
From: Mats PETERSSON [mailto:xxxxx@3dlabs.com]
Sent: Thursday, October 07, 2004 2:48 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Returning STATUS_INSUFFICIENT_RESOURCES
Here’s a couple of (obvious) pieces of advice. I’m not trying to “dump
you down”, but rather starting from scratch because I’m not sure how
familiar you are with driver debugging. 0. Break into the debugger and
check what’s on the stack. If it’s locked up in a loop in your driver
(or somethign called by your driver), it will usually give you some clue
of what’s going on. 1. Turn of Low Resource Simulation in Driver
Verifier. This makes sure that you’re chasing one type of problem at a
time, and it does by all appearances seem like you have more than one
problem (or a problem that IS NOT caused by low resources). 2. Use
!threads to identify the threads running at the time, and try to
identify what’s going on. !locks is also a useful command, as is
!stacks. Pay particular attention to calls that go into your driver,
obviously (note, you may have a call that goes into your driver, and
then into the kernel, for instance “KeWaitForSingleObject”. 3. Add more
debug prints to see what’s happening in your driver. 4. Being able move
the mouse isn’t really much evidence (other than the machine isn’t
completely hung at high IRQL, as the graphics driver and mouse driver
are both still working). But what is your driver doing? 5. Build a
simple trap for re-entrancy into your driver. In every place where your
driver is enteres, do something like:
static int GlobalReEntranceyCount = 0;
void SomeEntryPoint(…)
{
GlobalReEntrancyCount++;
if (GlobalReEntrancyCount > 1)
DebugPrint(-1, “Reentered into SomeEntryPoint\n”);
… Do some work
GlobalReEntrancyCount–;
}
This is not completely “secure” (particularly not on SMP systems), but
unless you’ve got code that is really synchronised, you’ll catch it
re-entering once in a while if it’s at all happening. Of course, running
multiple copies of the test-software will be helpful to see if you get
re-entrancy in the driver.
If you have re-entrancy, make sure that any shared data-objects (linked
list, reference counters, etc) are re-entrancy safe, by using
Mutex/SpinLock or similar so that your data structures don’t get screwed
up.
–
Mats
xxxxx@lists.osr.com wrote on 10/07/2004 07:07:02 AM:
Hi Mats,
> I do get an hang ocasionaly , wondering why?
Only under low-resource simulation, or at other times too? The hang is
other times too? But I am clueless, can you give me some commands in
windbg that I can test and reason out. I can move the mouse the cpu
and memory are not fully bust. But its shown the wait mouse icon and
is busy doing I do not know what? I do get my dbgprints but are a bit
slow, don’t seem to show any big processing by my driver also.
Thanks
-anurag
-----Original Message-----
From: Mats PETERSSON [mailto:xxxxx@3dlabs.com]
Sent: Wednesday, October 06, 2004 8:29 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Returning STATUS_INSUFFICIENT_RESOURCES
xxxxx@lists.osr.com wrote on 10/06/2004 03:38:13 PM:
> Hello Calvin,
>
> Yes.“low resource” is enabled in DV.
>
> But my question is when I go out of memory should I release the
> memory in hand and then return STATUS_INSUFFICIENT_RESOURCES or
> should I not release memory ?
You should release any memory related to the current request.
Otherwise, you’ll “leak” memory, which is bad… Of course, under
normal circumstances (Not Low Resource in DV), there’s only a small
chance of actually not being able to allocate non-paged pool, unless
some driver is not behaving properly (leaking non-paged pool, or
hogging it). However, it’s almost necessary that the driver can
survive a low-resource situation, even if it doesn’t actually do
anything usueful in this case. Doing a BSOD because of this is not a
recommended solution, and returning some error cod such as
INSUFFICIENT RESOURCES, is a good idea.
> I am not getting a bug check though . But what is the best
> practice??
>
> I do get an hang ocasionaly , wondering why?
Only under low-resource simulation, or at other times too?
Mats
>
> thanks & regards,
> Anurag
>
> -----Original Message-----
> From: Calvin Guan [mailto:xxxxx@ati.com]
> Sent: Wednesday, October 06, 2004 7:56 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Returning STATUS_INSUFFICIENT_RESOURCES Is "low
> resource" enabled in DV?
> -
> Calvin Guan Software Engineer
> ATI Technologies Inc. www.ati.com
> -----Original Message-----
> From: Anurag Sarin [mailto:xxxxx@divassoftware.com]
> Sent: October 6, 2004 3:03 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Returning STATUS_INSUFFICIENT_RESOURCES Hello
> Gurus, I wanted to get my basics straight. I am making a File system
> driver
and
> basically need UNICODE memory to hold file names . I see that I am
> out of nonpage memory some times. As the routine
> ExAllocatePoolWithTag does
> not always give me allocated memory, detecting this I pass my flow
> to
> Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
> Irp->IoStatus.Information = 0;
> IoCompleteRequest( Irp, IO_NO_INCREMENT );
> return STATUS_INSUFFICIENT_RESOURCES;
> Then I see that this out of memory thing is there some times as in
> the next Irp I do get an allocated memory ExAllocatePoolWithTag and
> every thing seems to works fine. I see no BSOD and driver just seem
> to work ok just that it hangs the system after some time.
>
> 1> Is "Not getting non page memory:- some time " a major flaw I need
> 1> to
> worry about and need to work with less memory ?
> 2> Before returning STATUS_INSUFFICIENT_RESOURCES do I free the
> 2> current
> unicode memory held by me.?? Will Held memory and returning
> STATUS_INSUFFICIENT_RESOURCES lead to memory fragmentation ??
> 3> Could hanging of my driver due to this observation .
>
> Any Ideas?
> Regards,
> Anurag
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.
> osronline.com/article.cfm?id=256 You are currently subscribed to
> ntdev
> as: unknown lmsubst tag argument:
‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> —
> Questions? First check the Kernel Driver FAQ at http://www.
> osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
> argument:
‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> —
> Questions? First check the Kernel Driver FAQ at http://www.
> osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
> argument:
‘’
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com ForwardSourceID:NT00004B5A
Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256 You are currently subscribed to ntdev
Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
ForwardSourceID:NT00004CCA
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to $subst(‘List.Name’) as:
$subst(‘Recip.EmailAddr’) To unsubscribe send a blank email to
$subst(‘Email.UnSub’)