Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


RE: Example with ExInitializeNPagedLookasideList with- NonPagedPoolMustSucceed will blue screen.

OSR_Community_UserOSR_Community_User Member Posts: 110,217
I think there should be used self defined Allocate routine instead of
ExAllocatePoolWithTag.
This routine is extremely simple and would look like this:

#include <ntifs.h>

PVOID
SafeAllocatePoolWithTag (
IN POOL_TYPE PoolType,
IN ULONG Length,
IN ULONG Tag
)
{
PVOID Result;

Result = ExAllocatePoolWithTag(PoolType, Length, Tag);

if (Result == NULL && (PoolType & 1) == NonPagedPool)
{
Result = ExAllocatePoolWithTag(PoolType |
MUST_SUCCEED_POOL_TYPE_MASK, Length, Tag);
}

return Result;
}

In this case Flags (in call to ExInitializeNPagedLookasideList) should
be zero or POOL_RAISE_IF_ALLOCATION_FAILURE.
This routine does a good job and I think non paged pool must succeed
is not unneccessary wasted.

Paul

> -----P?vodn? zpr?va-----
> Od: Taed Nelson [SMTP:[email protected]]
> Odesl?no: 10. kv?tna 2000 0:16
> Komu: NT Developers Interest List
> P?edm?t: [ntdev] RE: Example with ExInitializeNPagedLookasideList
> with Non PagedPoolMus tSucceed will blue screen.
>
> While I agree that it isn't a "hidden danger waiting to happen" in this
> particular SCSI case, I do think that anyone else's code that copied the
> same flag is scary. For example, for us, the bad code has been in the
> field
> for 2 years -- it wasn't until a particularly heavy load showed up that
> the
> entire "must succeed" pool got used up and the system blue screened.
> Worse
> yet, the external load didn't go away, and so the system kept rebooting
> for
> the customer every 15 minutes after it came up.
>
> The thing that bugs me is that that example source code (the only example
> of
> that function) did not follow the rules that are given in the DDK
> documenation:
> -- the flag that they passed was invalid; they should have used
> POOL_RAISE_IF_ALLOCATION_FAILURE, which I'm assuming is the same value
> [oddly, I could not find it in any header files]
> -- there was not comment in the code saying that they were doing
> something weird
> -- the "usage guidelines" for the must succeed pool specifically say
> that it is to be used ONLY for emergency situations after the normal pool
> allocation has failed, and that it is for temporary use only and must be
> freed as soon as possible.
>
>
>
> > -----Original Message-----
> > From: Paul Bunn [mailto:[email protected]]
> > Sent: Tuesday, 09 May, 2000 2:25 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] RE: Example with ExInitializeNPagedLookasideList with
> > Non PagedPoolMus tSucceed will blue screen.
> >
> >
> > I don't think it's a bug in the CLASS driver (just sloppy
> > programming --
> > programmers too lazy to do implement specific KeBugCheckEx
> > calls) -- since
> > every disk and tape driver is using this code, it is
> > obviously robust. The
> > class drivers dependent on
> > ScsiClassInitializeSrbLookasideList do not ask
> > for more than 4 elements, so the resource usage is extremely light.
> >
> > Regards,
> >
> > Paul Bunn, UltraBac.com, 425-644-6000
> > Microsoft MVP - WindowsNT/2000
> > http://www.ultrabac.com
> >
> >
> > -----Original Message-----
> > From: Taed Nelson [mailto:[email protected]]
> > Sent: Tuesday, May 09, 2000 11:08 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Example with ExInitializeNPagedLookasideList with
> > NonPagedPoolMus tSucceed will blue screen.
> >
> >
> > [I have already submitted this bug to the DDK bug reports,
> > but thought I'd
> > share it with all of you, since it's potentially very bad. I suggest
> > everyone search their code base for the same bug!]
> >
> > The only code example of ExInitializeNPagedLookasideList in
> > either the NT
> > 4.0 DDK or MSDN is in CLASS.C, which is a SCSI driver. However, this
> > example specifies the flag NonPagedPoolMustSucceed.
> >
> > There are two problems with this.
> >
> > First, that flag is not valid. The documentation for
> > ExInitializeNPagedLookasideList clearly states that the flags
> > should nearly
> > always be 0, except for the rare POOL_RAISE_IF_ALLOCATION_FAILURE.
> >
> > Second, if the flag NonPagedPoolMustSucceed is specified, all
> > allocations
> > for that lookaside list (not just the initialization) will be
> > from the "must
> > succeed" pool.
> >
> > The "must succeed" pool is a very scarce resource, which is
> > only about 16 KB
> > large. If the lookaside list happens to exhaust that memory,
> > it will cause
> > a blue screen, namely event 0x00000041, MUST_SUCCEED_POOL_EMPTY.
> >
> > A programmer here had copied the code from the DDK for our
> > project, and we
> > would get that blue screen under high load. It took us a few
> > days to track
> > it down to using the "must succeed" pool instead of the normal pool.
> >
> > I feel that is a serious bug in the CLASS.C code, which will
> > cause bugs in
> > other people's code since it is the only example of the
> > ExInitializeNPagedLookasideList function.
> >
> > ---
> > You are currently subscribed to ntdev as: [email protected]
> > To unsubscribe send a blank email to $subst('Email.Unsub')
> >
>
> ---
> You are currently subscribed to ntdev as: [email protected]
> To unsubscribe send a blank email to $subst('Email.Unsub')
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online