- Allow the thread that called LdrShutdownProcess to forcefully acquire critical sections (the loader lock in particular).
This fixes the race condition where ExitProcess might terminate a thread holding the loader lock and subsequently call LdrShutdownProcess. That would then result in a deadlock because LdrShutdownProcess cannot acquire the loader lock.
This is a pretty ugly hack... but at least Windows does it the same way.
Fixes hangs after the summary line when running mshtml tests.
CORE-8624 #resolve

svn path=/trunk/; revision=64702
This commit is contained in:
Thomas Faber 2014-10-12 20:45:32 +00:00
parent ae24fd4e41
commit b62c758526

View file

@ -23,6 +23,9 @@ static RTL_CRITICAL_SECTION_DEBUG RtlpStaticDebugInfo[MAX_STATIC_CS_DEBUG_OBJECT
static BOOLEAN RtlpDebugInfoFreeList[MAX_STATIC_CS_DEBUG_OBJECTS];
LARGE_INTEGER RtlpTimeout;
extern BOOLEAN LdrpShutdownInProgress;
extern HANDLE LdrpShutdownThreadId;
/* FUNCTIONS *****************************************************************/
/*++
@ -125,6 +128,18 @@ RtlpWaitForCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
if (CriticalSection->DebugInfo)
CriticalSection->DebugInfo->EntryCount++;
/*
* If we're shutting down the process, we're allowed to acquire any
* critical sections by force (the loader lock in particular)
*/
if (LdrpShutdownInProgress &&
LdrpShutdownThreadId == NtCurrentTeb()->RealClientId.UniqueThread)
{
DPRINT("Forcing ownership of critical section %p\n", CriticalSection);
CriticalSection->LockCount = 0;
return STATUS_SUCCESS;
}
for (;;)
{
/* Increase the number of times we've had contention */