on mutex deadlock, get a backtrace of the thread that we're deadlocked
with
This commit is contained in:
@@ -28,6 +28,10 @@
|
|||||||
#define PID_BASED_THREADS
|
#define PID_BASED_THREADS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
#include "archutils/Win32/crash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_THREADS 128
|
#define MAX_THREADS 128
|
||||||
|
|
||||||
static const unsigned int UnknownThreadID = 0xFFFFFFFF;
|
static const unsigned int UnknownThreadID = 0xFFFFFFFF;
|
||||||
@@ -480,9 +484,12 @@ RageMutexImpl::~RageMutexImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CrashDeadlocked()
|
static ThreadSlot *FindThread( DWORD id )
|
||||||
{
|
{
|
||||||
sm_crash();
|
for( int i = 0; i < MAX_THREADS; ++i )
|
||||||
|
if( g_ThreadSlots[i].threadid == id )
|
||||||
|
return &g_ThreadSlots[i];
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageMutexImpl::Lock()
|
void RageMutexImpl::Lock()
|
||||||
@@ -521,11 +528,8 @@ void RageMutexImpl::Lock()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: We want a stack trace of *all* threads if this happened, so we can
|
ThreadSlot *slot = FindThread( LockedBy );
|
||||||
* tell who we're deadlocked with. We can't use CHECKPOINT, since that uses
|
Crash_BacktraceThread( slot? slot->ThreadHandle:NULL );
|
||||||
* locks. Crash in a function, so we can see it on the stack (so we know
|
|
||||||
* we didn't crash somewhere else above.) */
|
|
||||||
CrashDeadlocked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageMutexImpl::Unlock()
|
void RageMutexImpl::Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user