Author: tfaber
Date: Wed Sep 4 19:53:59 2013
New Revision: 59992
URL:
http://svn.reactos.org/svn/reactos?rev=59992&view=rev
Log:
[KERNEL32]
- Fix LoaderLock assert in TerminateThread. Spotted by Amine
Modified:
trunk/reactos/dll/win32/kernel32/client/thread.c
Modified: trunk/reactos/dll/win32/kernel32/client/thread.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/thread.c [iso-8859-1] Wed Sep 4 19:53:59
2013
@@ -571,8 +571,10 @@
IN DWORD dwExitCode)
{
NTSTATUS Status;
+#if DBG
PRTL_CRITICAL_SECTION LoaderLock;
THREAD_BASIC_INFORMATION ThreadInfo;
+#endif /* DBG */
/* Check for invalid thread handle */
if (!hThread)
@@ -582,6 +584,7 @@
return FALSE;
}
+#if DBG
/* Get the loader lock */
LoaderLock = NtCurrentPeb()->LoaderLock;
if (LoaderLock)
@@ -592,13 +595,14 @@
&ThreadInfo,
sizeof(ThreadInfo),
NULL);
- if (!NT_SUCCESS(Status))
- {
- /* Assert that we don't hold the loader lock */
- ASSERT(NtCurrentTeb()->ClientId.UniqueThread !=
ThreadInfo.ClientId.UniqueThread);
- ASSERT(NtCurrentTeb()->ClientId.UniqueThread !=
LoaderLock->OwningThread);
- }
- }
+ if (NT_SUCCESS(Status))
+ {
+ /* If terminating the current thread, we must not hold the loader lock */
+ if (NtCurrentTeb()->ClientId.UniqueThread ==
ThreadInfo.ClientId.UniqueThread)
+ ASSERT(NtCurrentTeb()->ClientId.UniqueThread !=
LoaderLock->OwningThread);
+ }
+ }
+#endif /* DBG */
/* Now terminate the thread */
Status = NtTerminateThread(hThread, dwExitCode);