mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 09:50:43 +00:00
[NTDLL] Acquire LdrpLoaderLock in LdrpInitializeThread
This is required to protect against a race with LdrShutdownThread, which can lead to all kinds of problems, including deadlocks.
This commit is contained in:
parent
72951421e6
commit
e302bacd7e
1 changed files with 9 additions and 1 deletions
|
@ -517,6 +517,9 @@ LdrpInitializeThread(IN PCONTEXT Context)
|
||||||
NtCurrentTeb()->RealClientId.UniqueProcess,
|
NtCurrentTeb()->RealClientId.UniqueProcess,
|
||||||
NtCurrentTeb()->RealClientId.UniqueThread);
|
NtCurrentTeb()->RealClientId.UniqueThread);
|
||||||
|
|
||||||
|
/* Acquire the loader Lock */
|
||||||
|
RtlEnterCriticalSection(&LdrpLoaderLock);
|
||||||
|
|
||||||
/* Allocate an Activation Context Stack */
|
/* Allocate an Activation Context Stack */
|
||||||
DPRINT("ActivationContextStack %p\n", NtCurrentTeb()->ActivationContextStackPointer);
|
DPRINT("ActivationContextStack %p\n", NtCurrentTeb()->ActivationContextStackPointer);
|
||||||
Status = RtlAllocateActivationContextStack(&NtCurrentTeb()->ActivationContextStackPointer);
|
Status = RtlAllocateActivationContextStack(&NtCurrentTeb()->ActivationContextStackPointer);
|
||||||
|
@ -526,7 +529,7 @@ LdrpInitializeThread(IN PCONTEXT Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we are not shutting down */
|
/* Make sure we are not shutting down */
|
||||||
if (LdrpShutdownInProgress) return;
|
if (LdrpShutdownInProgress) goto Exit;
|
||||||
|
|
||||||
/* Allocate TLS */
|
/* Allocate TLS */
|
||||||
LdrpAllocateTls();
|
LdrpAllocateTls();
|
||||||
|
@ -633,6 +636,11 @@ LdrpInitializeThread(IN PCONTEXT Context)
|
||||||
RtlDeactivateActivationContextUnsafeFast(&ActCtx);
|
RtlDeactivateActivationContextUnsafeFast(&ActCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
|
||||||
|
/* Release the loader lock */
|
||||||
|
RtlLeaveCriticalSection(&LdrpLoaderLock);
|
||||||
|
|
||||||
DPRINT("LdrpInitializeThread() done\n");
|
DPRINT("LdrpInitializeThread() done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue