Author: tfaber Date: Sun Oct 12 20:45:32 2014 New Revision: 64702
URL: http://svn.reactos.org/svn/reactos?rev=64702&view=rev Log: [RTL] - 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
Modified: trunk/reactos/lib/rtl/critical.c
Modified: trunk/reactos/lib/rtl/critical.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/critical.c?rev=6470... ============================================================================== --- trunk/reactos/lib/rtl/critical.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/critical.c [iso-8859-1] Sun Oct 12 20:45:32 2014 @@ -23,6 +23,9 @@ static BOOLEAN RtlpDebugInfoFreeList[MAX_STATIC_CS_DEBUG_OBJECTS]; LARGE_INTEGER RtlpTimeout;
+extern BOOLEAN LdrpShutdownInProgress; +extern HANDLE LdrpShutdownThreadId; + /* FUNCTIONS *****************************************************************/
/*++ @@ -124,6 +127,18 @@
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 (;;) {