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=647…
==============================================================================
--- 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 (;;)
{
Author: hbelusca
Date: Sun Oct 12 17:23:20 2014
New Revision: 64701
URL: http://svn.reactos.org/svn/reactos?rev=64701&view=rev
Log:
[NTVDM]
- Move the stack frame indices to where they belong (this is the stack layout when an interrupt is called).
- In the bootstrap interrupt, modify the CS:IP stored in the stack instead of the current CS:IP of the CPU, so that we can clean up everything and the interrupt return correctly, instead of breaking everything... (some apps wouldn't start with the original code^^). This is an addendum/fix to revision 64521.
Modified:
trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c
trunk/reactos/subsystems/ntvdm/cpu/callback.h
trunk/reactos/subsystems/ntvdm/int32.h
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] Sun Oct 12 17:23:20 2014
@@ -295,9 +295,18 @@
/* Load DOS */
DosBootsectorInitialize();
- /* Position CPU to 0000:7C00 to boot the OS */
- setCS(0x0000);
- setIP(0x7C00);
+
+ /*
+ * Position CPU to 0000:7C00 to boot the OS.
+ *
+ * Since we are called via the INT32 mechanism, we need to correctly set
+ * CS:IP, not by changing the current one (otherwise the interrupt could
+ * not be clean up and return properly), but by changing the CS:IP in the
+ * stack, so that when the interrupt returns, the modified CS:IP is popped
+ * off the stack and the CPU is correctly repositioned.
+ */
+ Stack[STACK_CS] = 0x0000;
+ Stack[STACK_IP] = 0x7C00;
DPRINT1("<-- BiosBootstrapLoader\n");
}
Modified: trunk/reactos/subsystems/ntvdm/cpu/callback.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/cpu/callb…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/cpu/callback.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/cpu/callback.h [iso-8859-1] Sun Oct 12 17:23:20 2014
@@ -29,16 +29,6 @@
USHORT NextOffset;
} CALLBACK16, *PCALLBACK16;
-//
-// WARNING WARNING!!
-// If you're changing the indices here, you then need to
-// also fix the BOP code in callback.c !!!!!!!!!!!!!!!!!
-//
-#define STACK_INT_NUM 0
-#define STACK_IP 1
-#define STACK_CS 2
-#define STACK_FLAGS 3
-
/* FUNCTIONS ******************************************************************/
VOID
Modified: trunk/reactos/subsystems/ntvdm/int32.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/int32.h?r…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/int32.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/int32.h [iso-8859-1] Sun Oct 12 17:23:20 2014
@@ -18,6 +18,21 @@
/* 32-bit Interrupt Identifiers */
#define EMULATOR_MAX_INT32_NUM 0xFF + 1
+
+
+//
+// WARNING WARNING!!
+// If you're changing the stack indices here, you then need
+// to also fix the Int16To32 handler code in int32.c !!
+//
+
+// Custom variable pushed onto the stack for INT32 interrupts
+#define STACK_INT_NUM 0
+
+// This is the standard stack layout for an interrupt
+#define STACK_IP 1
+#define STACK_CS 2
+#define STACK_FLAGS 3
extern const ULONG Int16To32StubSize;