25#define UDF_BUG_CHECK_ID UDF_FILE_DLD
29#define RESOURCE_EVENT_TAG 'vEeR'
31#define RESOURCE_SEMAFORE_TAG 'eSeR'
33#define RESOURCE_TABLE_TAG 'aTeR'
36#define DLD_MAX_REC_LEVEL 40
54 UDFPrint((
"Deadlock Detector is designed for uniprocessor machines only!\n"));
73 ULONG FirstEmpty = -1;
78 }
else if (FirstEmpty == -1 && !Temp->
ThreadId) {
86 if (FirstEmpty == -1) {
87 UDFPrint((
"Not enough table entries. Try to increase MaxThrdCount on next build"));
103 ULONG FirstEmpty = -1;
128 if (ThrdOwner == ThrdStruct) {
130 UDFPrint((
"DLD: *********DEADLOCK DETECTED*********\n"));
138 UDFPrint((
"DLD: *********DEADLOCK DETECTED*********\n"));
140 for (
int j=RecLevel+1;
j<=
i;
j++) {
141 UDFPrint((
" awaited by thread %x at (BugCheckId:%x:Line:%d) holding resource %x\n",
157 UDFPrint((
" awaited by thread %x at (BugCheckId:%x:Line:%d) holding resource %x\n",
208 for (
i=0;
i<
Resource->OwnerThreads[0].TableSize;
i++) {
209 if (
Resource->OwnerTable[
i].OwnerThread) {
231 ULONG ResourceWaitCount = 0;
239 ResourceWaitCount = 0;
242 UDFPrint((
" which thread %x has tried to acquire at (BugCheckId:%x:Line:%d)\n",
243 ThrdStruct->ThreadId,
244 ThrdStruct->BugCheckId,
270 if (!(
Resource->ExclusiveWaiters)) {
276 if (!(
Resource->ExclusiveWaiters)) {
284 Resource->NumberOfExclusiveWaiters++;
303 ThrdStruct->
Line = 0;
324 if (!
Resource->ActiveCount)
goto SimpleAcquire;
326 Resource->OwnerThreads[0].OwnerCount++;
339 Resource->OwnerThreads[0].OwnerCount = 1;
354 if (!(
Resource->OwnerThreads[1].OwnerThread)) FirstEmptyEntry = &(
Resource->OwnerThreads[1]);
356 CurrentEntry =
Resource->OwnerTable;
359 while (CurrentEntry != LastEntry) {
362 *((
PULONG)(CurrentThread + 0x136)) = CurrentEntry -
Resource->OwnerTable;
366 FirstEmptyEntry = CurrentEntry;
370 if (FirstEmptyEntry) {
372 *((
PULONG)(CurrentThread + 0x136)) = FirstEmptyEntry -
Resource->OwnerTable;
373 return FirstEmptyEntry;
380 if (OldSize)
NewSize = OldSize + 4;
390 *((
PULONG)(CurrentThread + 0x136)) = OldSize;
393 return &(NewEntry[OldSize]);
412 Resource->Flag &= ~ResourceOwnedExclusive;
415 Resource->OwnerThreads[1].OwnerCount = 1;
422 Resource->OwnerThreads[0].OwnerCount++;
440 if (!(
Resource->NumberOfExclusiveWaiters)) {
479 ThrdStruct->
Line = 0;
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
#define RESOURCE_SEMAFORE_TAG
Resource semaphore (SharedWaiters)
POWNER_ENTRY DLDpFindCurrentThread(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
PTHREAD_STRUCT DLDAllocFindThread(ULONG ThreadId)
VOID DLDpWaitForResource(IN PERESOURCE Resource, IN DISPATCHER_HEADER *DispatcherObject, IN PTHREAD_STRUCT ThrdStruct)
#define RESOURCE_EVENT_TAG
Resource event (ExclusiveWaiters)
BOOLEAN DLDProcessThread(PTHREAD_STRUCT ThrdOwner, PTHREAD_STRUCT ThrdStruct, PERESOURCE Resource, ULONG RecLevel)
TRUE Indicates deadlock.
THREAD_REC_BLOCK DLDThreadAcquireChain[DLD_MAX_REC_LEVEL]
ULONG MaxThreadCount
Maximum supported number of threads (initialized by DLDInit())
VOID DLDpAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread, IN KIRQL oldIrql, IN ULONG BugCheckId, IN ULONG Line)
#define DLD_MAX_REC_LEVEL
Maxmum recurse level while exploring thread-resource aquisition graf.
PTHREAD_STRUCT DLDFindThread(ULONG ThreadId)
VOID DLDAcquireShared(PERESOURCE Resource, ULONG BugCheckId, ULONG Line, BOOLEAN WaitForExclusive)
#define RESOURCE_TABLE_TAG
Resource owner table (OwnerTable)
LARGE_INTEGER DLDpTimeout
4 sec
VOID DLDAcquireExclusive(PERESOURCE Resource, ULONG BugCheckId, ULONG Line)
VOID DLDInit(ULONG MaxThrdCount)
Initialize deadlock detector.
ULONG DLDpResourceTimeoutCount
8 sec
BOOLEAN DLDProcessResource(PERESOURCE Resource, PTHREAD_STRUCT ThrdStruct, ULONG RecLevel)
TRUE Indicates deadlock.
PTHREAD_STRUCT DLDThreadTable
Waiters table.
#define DLDAllocatePool(size)
struct _THREAD_STRUCT * PTHREAD_STRUCT
#define ResourceOwnedExclusive
#define DLDFreePool(addr)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define PsGetCurrentThread()
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
_Must_inspect_result_ _In_ USHORT NewSize
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
VOID NTAPI KeInitializeSemaphore(IN PKSEMAPHORE Semaphore, IN LONG Count, IN LONG Limit)
ERESOURCE_THREAD OwnerThread
PERESOURCE HoldingResource
ERESOURCE_THREAD ThreadId
PERESOURCE WaitingResource
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
struct _OWNER_ENTRY * POWNER_ENTRY
ULONG_PTR ERESOURCE_THREAD
struct _KSEMAPHORE * PKSEMAPHORE