From 5b9077f992eaa0d1ea99343901795923085b57c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 12 Nov 2015 20:24:18 +0000 Subject: [PATCH] [CONSRV] Add diagnostic dprints to try to understand the problems described in CORE-9742 and CORE-10510 svn path=/trunk/; revision=69879 --- reactos/subsystems/win32/csrsrv/thredsup.c | 2 +- .../winsrv/consrv/frontends/gui/guiterm.c | 29 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/reactos/subsystems/win32/csrsrv/thredsup.c b/reactos/subsystems/win32/csrsrv/thredsup.c index 703ca58a80f..0cc314cc2d5 100644 --- a/reactos/subsystems/win32/csrsrv/thredsup.c +++ b/reactos/subsystems/win32/csrsrv/thredsup.c @@ -440,7 +440,7 @@ CsrThreadRefcountZero(IN PCSR_THREAD CsrThread) Status = NtClose(CsrThread->ThreadHandle); if (!NT_SUCCESS(Status)) - DPRINT1("CSR: NtClose failed, we are going to ASSERT, Status = 0x%08lx; [%02x,%02x] Process: 0x%p; ThreadHandle: 0x%p\n", + DPRINT1("CSR: NtClose failed, we are going to ASSERT, Status = 0x%08lx; [0x%x, 0x%x] Process: 0x%p; ThreadHandle: 0x%p\n", Status, CsrThread->ClientId.UniqueProcess, CsrThread->ClientId.UniqueThread, CsrProcess, CsrThread->ThreadHandle); ASSERT(NT_SUCCESS(Status)); diff --git a/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c b/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c index 72b1028aee2..4aff1bbf460 100644 --- a/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c +++ b/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c @@ -147,6 +147,7 @@ GuiConsoleInputThread(PVOID Param) PGUI_INIT_INFO GuiInitInfo = (PGUI_INIT_INFO)Param; DESKTOP_CONSOLE_THREAD DesktopConsoleThreadInfo; ULONG_PTR InputThreadId = HandleToUlong(NtCurrentTeb()->ClientId.UniqueThread); + HANDLE hThread = NULL; LONG WindowCount = 0; MSG msg; @@ -166,8 +167,21 @@ GuiConsoleInputThread(PVOID Param) if (!NT_SUCCESS(Status)) goto Quit; /* Connect this CSR thread to the USER subsystem */ + { + PCSR_THREAD CurrThread = CsrGetClientThread(); + + DPRINT1("CsrConnectToUser being called; [0x%x, 0x%x]...\n", + CurrThread->ClientId.UniqueProcess, CurrThread->ClientId.UniqueThread); + pcsrt = CsrConnectToUser(); if (pcsrt == NULL) goto Quit; + hThread = pcsrt->ThreadHandle; + + DPRINT1("CsrConnectToUser was successfully called; [0x%x, 0x%x] -- hThread = 0x%p, pcsrt->Process = 0x%p; pcsrt->ThreadHandle = 0x%p from [0x%x, 0x%x]\n", + CurrThread->ClientId.UniqueProcess, CurrThread->ClientId.UniqueThread, + hThread, pcsrt->Process, pcsrt->ThreadHandle, + pcsrt->ClientId.UniqueProcess, pcsrt->ClientId.UniqueThread); + } /* Assign the desktop to this thread */ if (!SetThreadDesktop(DesktopConsoleThreadInfo.DesktopHandle)) goto Quit; @@ -307,7 +321,20 @@ Quit: CloseDesktop(DesktopConsoleThreadInfo.DesktopHandle); // NtUserCloseDesktop /* Cleanup CSR thread */ - if (pcsrt) CsrDereferenceThread(pcsrt); + if (pcsrt) + { + PCSR_THREAD CurrThread = CsrGetClientThread(); + + DPRINT1("CsrDereferenceThread being called; [0x%x, 0x%x] -- hThread = 0x%p, pcsrt->Process = 0x%p; pcsrt->ThreadHandle = 0x%p from [0x%x, 0x%x]\n", + CurrThread->ClientId.UniqueProcess, CurrThread->ClientId.UniqueThread, + hThread, pcsrt->Process, pcsrt->ThreadHandle, + pcsrt->ClientId.UniqueProcess, pcsrt->ClientId.UniqueThread); + + if (hThread != pcsrt->ThreadHandle) + DPRINT1("WARNING!! hThread != pcsrt->ThreadHandle, you may expect crashes soon!!\n"); + + CsrDereferenceThread(pcsrt); + } /* Exit the thread */ RtlExitUserThread(Status);