Dmitry Timoshkov : ntdll: Don' t allow blocking on a critical section during process termination.

Alexandre Julliard julliard at winehq.org
Thu Nov 29 15:09:36 CST 2018


Module: wine
Branch: stable
Commit: 9a3c62249c746710d47aa02709e75f1bf33957a1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9a3c62249c746710d47aa02709e75f1bf33957a1

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Aug  7 16:03:16 2018 +0800

ntdll: Don't allow blocking on a critical section during process termination.

As a result HeapLock() no longer blocks process termination since underlying
implementation uses a critical section. However this should be considered as
a minor side effect because applications shouldn't depend on this behaviour.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 7def0f200f117a5a72ce454004ac4fd600ef8a4b)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/kernel32/tests/loader.c | 4 +++-
 dlls/ntdll/critsection.c     | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 5dc9308..7066bca 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -1836,6 +1836,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
              * doesn't call the DLL entry point on process detach either.
              */
             HeapLock(GetProcessHeap());
+todo_wine
             ok(0, "dll_entry_point: process should already deadlock\n");
             break;
         }
@@ -2690,6 +2691,7 @@ static void test_ExitProcess(void)
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
     ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 5000);
+todo_wine
     ok(ret == WAIT_TIMEOUT || broken(ret == WAIT_OBJECT_0) /* XP */, "child process should fail to terminate\n");
     if (ret != WAIT_OBJECT_0)
     {
@@ -2699,6 +2701,7 @@ static void test_ExitProcess(void)
     ret = WaitForSingleObject(pi.hProcess, 1000);
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     GetExitCodeProcess(pi.hProcess, &ret);
+todo_wine
     ok(ret == 201 || broken(ret == 1) /* XP */, "expected exit code 201, got %u\n", ret);
     if (*child_failures)
     {
@@ -2714,7 +2717,6 @@ static void test_ExitProcess(void)
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
     ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 5000);
-todo_wine
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     if (ret != WAIT_OBJECT_0)
     {
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index e405b08..42e432c 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -436,6 +436,15 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit )
 NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
 {
     LONGLONG timeout = NtCurrentTeb()->Peb->CriticalSectionTimeout.QuadPart / -10000000;
+
+    /* Don't allow blocking on a critical section during process termination */
+    if (RtlDllShutdownInProgress())
+    {
+        WARN( "process %s is shutting down, returning STATUS_SUCCESS\n",
+              debugstr_w(NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer) );
+        return STATUS_SUCCESS;
+    }
+
     for (;;)
     {
         EXCEPTION_RECORD rec;




More information about the wine-cvs mailing list