weird bug check with ExAllocateFromNPagedLookasideList

Maybe I’m just missing something obvious but I’m hoping another pair of eyes
can help.

I grab a buffer in a dispatch routine via ExAllocateFromNPagedLookasideList,
send it off to a Kernel Thread for processing, and then wait with a
KeWaitForSingleObject, all in the dispatch routine.

I have the buffer properly allocated with a LIST_ENTRY at the beginning.

Immediately after allocating the buffer I zero it out. If I zero it field
by field (omitting the list header, of course) everything works just fine.

However, if I zero it with RtlZeroMemory as below, I get a bug check 0xB8 in
the Kernel Thread (something about a wait during an APC routine). Notice I
am being careful not to clear the list header.

RtlZeroMemory(((UCHAR*)myContext)+sizeof(LIST_ENTRY),
sizeof(MY_CONTEXT)-sizeof(LIST_ENTRY));

Is there some other stuff that ExAllocateFromNPagedLookasideList stores in
the buffer that I shouldn’t touch? I can work around this but I’d like to
understand what might be going on.

Thanks.

Neil

You should not need to worry about a LIST_ENTRY, the data area you get back
from ExAllocateFromNPagedLookasideList is all yours. Remove the list
stuff, run if again, and post the !analyze -v output if the crash occurs
again.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply

“Neil Weicher” wrote in message news:xxxxx@ntfsd…
> Maybe I’m just missing something obvious but I’m hoping another pair of
> eyes
> can help.
>
> I grab a buffer in a dispatch routine via
> ExAllocateFromNPagedLookasideList,
> send it off to a Kernel Thread for processing, and then wait with a
> KeWaitForSingleObject, all in the dispatch routine.
>
> I have the buffer properly allocated with a LIST_ENTRY at the beginning.
>
> Immediately after allocating the buffer I zero it out. If I zero it
> field
> by field (omitting the list header, of course) everything works just
> fine.
>
> However, if I zero it with RtlZeroMemory as below, I get a bug check 0xB8
> in
> the Kernel Thread (something about a wait during an APC routine). Notice
> I
> am being careful not to clear the list header.
>
> RtlZeroMemory(((UCHAR*)myContext)+sizeof(LIST_ENTRY),
> sizeof(MY_CONTEXT)-sizeof(LIST_ENTRY));
>
> Is there some other stuff that ExAllocateFromNPagedLookasideList stores
> in
> the buffer that I shouldn’t touch? I can work around this but I’d like to
> understand what might be going on.
>
> Thanks.
>
> Neil
>
>

Running windbg on this code could supply the answer in only a couple of
minutes.

“Neil Weicher” wrote in message news:xxxxx@ntfsd…
> Maybe I’m just missing something obvious but I’m hoping another pair of
> eyes
> can help.
>
> I grab a buffer in a dispatch routine via
> ExAllocateFromNPagedLookasideList,
> send it off to a Kernel Thread for processing, and then wait with a
> KeWaitForSingleObject, all in the dispatch routine.
>
> I have the buffer properly allocated with a LIST_ENTRY at the beginning.
>
> Immediately after allocating the buffer I zero it out. If I zero it field
> by field (omitting the list header, of course) everything works just fine.
>
> However, if I zero it with RtlZeroMemory as below, I get a bug check 0xB8
> in
> the Kernel Thread (something about a wait during an APC routine). Notice
> I
> am being careful not to clear the list header.
>
> RtlZeroMemory(((UCHAR*)myContext)+sizeof(LIST_ENTRY),
> sizeof(MY_CONTEXT)-sizeof(LIST_ENTRY));
>
> Is there some other stuff that ExAllocateFromNPagedLookasideList stores in
> the buffer that I shouldn’t touch? I can work around this but I’d like to
> understand what might be going on.
>
> Thanks.
>
> Neil
>
>

I assume the LIST_ENTRY is yours; as another poster wrote, the buffer
returned from ExAllocateFromNPagedLookasideList() is all yours. Clear
the entire area using RtlZeroMemory() and then intialized the list
header using InitializeListHead().

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Neil Weicher
Sent: Thursday, December 14, 2006 12:36 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] weird bug check with
ExAllocateFromNPagedLookasideList

Maybe I’m just missing something obvious but I’m hoping
another pair of eyes can help.

I grab a buffer in a dispatch routine via
ExAllocateFromNPagedLookasideList,
send it off to a Kernel Thread for processing, and then wait
with a KeWaitForSingleObject, all in the dispatch routine.

I have the buffer properly allocated with a LIST_ENTRY at the
beginning.

Immediately after allocating the buffer I zero it out. If I
zero it field by field (omitting the list header, of course)
everything works just fine.

However, if I zero it with RtlZeroMemory as below, I get a
bug check 0xB8 in the Kernel Thread (something about a wait
during an APC routine). Notice I am being careful not to
clear the list header.

RtlZeroMemory(((UCHAR*)myContext)+sizeof(LIST_ENTRY),
sizeof(MY_CONTEXT)-sizeof(LIST_ENTRY));

Is there some other stuff that
ExAllocateFromNPagedLookasideList stores in the buffer that I
shouldn’t touch? I can work around this but I’d like to
understand what might be going on.