Hi All,
In my mini-filter driver, in preclose() operation, i am calling flushcahe code which leads t o system crash.
In the memory dump, it shows that while acquiring PagingIoResource it crashes while doing hal!KeAcquireInStackQueuedSpinLock.
Flushcache code:
int FlushCache(PFILE_OBJECT pFileObject)
{
PFSRTL_COMMON_FCB_HEADER pFcbHeader = NULL;
LARGE_INTEGER lnWaitTime;
if(FALSE == CcIsFileCached(pFileObject))
{
return 0;
}
pFcbHeader = (PFSRTL_COMMON_FCB_HEADER)(pFileObject->FsContext);
if(NULL != pFileObject->SectionObjectPointer)
{
KeEnterCriticalRegion();
Retry:
if ( (ExAcquireResourceExclusiveLite(pFcbHeader->Resource, TRUE)) )
{
//// ERROR HERE IN MINI DUMP
if((ExAcquireResourceExclusiveLite(pFcbHeader->PagingIoResource,FALSE)))
{
CcFlushCache(pFileObject->SectionObjectPointer, 0, 0, NULL);
if(NULL != pFileObject->SectionObjectPointer->ImageSectionObject)
{
MmFlushImageSection(pFileObject->SectionObjectPointer,
MmFlushForWrite);
}
if (NULL != pFileObject->SectionObjectPointer->DataSectionObject)
{
CcPurgeCacheSection(pFileObject->SectionObjectPointer,
NULL,0,FALSE);
}
ExReleaseResourceLite(pFcbHeader->PagingIoResource);
ExReleaseResourceLite(pFcbHeader->Resource);
}
else
{
ExReleaseResourceLite(pFcbHeader->Resource);
lnWaitTime.QuadPart = -500000;
KeDelayExecutionThread(KernelMode,FALSE,&lnWaitTime);
goto Retry;
}
}
else
{
lnWaitTime.QuadPart = -500000;
KeDelayExecutionThread(KernelMode,FALSE,&lnWaitTime);
goto Retry;
}
KeLeaveCriticalRegion();
}
return 0;
}
Memory Dump:
1: kd> !analyze -v
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
Unknown bugcheck code (1000000a)
Unknown bugcheck description
Arguments:
Arg1: 00000034
Arg2: 00000002
Arg3: 00000001
Arg4: 806e4a16
Debugging Details:
DEFAULT_BUCKET_ID: DRIVER_FAULT
BUGCHECK_STR: 0xA
LAST_CONTROL_TRANSFER: from f698cbb6 to 806e4a16
STACK_TEXT:
f8892bac f698cbb6 00000000 00000000 00000001 hal!KeAcquireInStackQueuedSpinLock+0x26
f8892bcc f69916c1 813c3400 00060006 82ae2ff6 TestFilter!FlushCache+0x86 [flushcache.c]
f8892bf0 bae5cdeb ff9b966c f8892c3c f8892c6c TestFilter!PreCloseOperation+0x91 [operations.c]
f8892c1c bae44888 00000001 00000002 f8892c6c fltmgr!FltvPreOperation+0x3f
f8892c7c bae462a0 00892cc4 827b6fdc f8892cc4 fltmgr!FltpPerformPreCallbacks+0x2d4
f8892c90 bae46c48 f8892cc4 00000000 819f1ca0 fltmgr!FltpPassThroughInternal+0x32
f8892cac bae47059 f8892cc4 813c3400 822f5f38 fltmgr!FltpPassThrough+0x1c2
f8892cdc 804eeeb1 819f1ca0 827b6de0 806e4428 fltmgr!FltpDispatch+0x10d
f8892cec 80656128 827b6df0 827b6de0 813c3400 nt!IopfCallDriver+0x31
f8892d10 805827b4 813c33e8 813c33d8 00000000 nt!IovCallDriver+0xa0
f8892d48 805b9e25 003c3400 00000000 813c3400 nt!IopDeleteFile+0x132
f8892d64 805ba278 813c3400 00000001 80561e80 nt!ObpRemoveObjectRoutine+0xdf
f8892d74 80563720 822ef830 80537757 00000000 nt!ObpProcessRemoveObjectQueue+0x36
f8892dac 805ce794 00000000 00000000 00000000 nt!ExWorkerQueue
f8892ddc 805450ce 80537668 00000000 00000000 nt!PspSystemThreadStartup+0x34
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16
FOLLOWUP_IP:
TestFilter!FlushCache+86 [flushcache.c]
f698cbb6 0fb6d0 movzx edx,al
FOLLOWUP_NAME: MachineOwner
SYMBOL_NAME: TestFilter!FlushCache+86
MODULE_NAME: TestFilter
IMAGE_NAME: TestFilter.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 4551e602
STACK_COMMAND: kb
BUCKET_ID: 0xA_TestFilter!FlushCache+86
Followup: MachineOwner
Thanks for your help,
Mahesh