rpcrt4: Do nothing when DllMain is called because the process is exiting.

Vincent Povirk madewokherd at gmail.com
Thu Mar 29 11:02:59 CDT 2012


For bug 29147. I don't think this will solve the bug, but it seems
rpcrt4's cleanup code is causing trouble during a process shutdown,
and probably obscuring the real problem.

I've read in multiple places that we cannot rely on the heap to be in
a consistent state, or on the dll's we use to still be loaded, during
process shutdown.
-------------- next part --------------
From 4fcc9f7b6346d17df95578117c634e3c8d0b7d7c Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 29 Mar 2012 10:52:29 -0500
Subject: [PATCH] rpcrt4: Do nothing when DllMain is called because the
 process is exiting.

---
 dlls/rpcrt4/rpcrt4_main.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/rpcrt4/rpcrt4_main.c b/dlls/rpcrt4/rpcrt4_main.c
index 53f3bbd..02931f9 100644
--- a/dlls/rpcrt4/rpcrt4_main.c
+++ b/dlls/rpcrt4/rpcrt4_main.c
@@ -138,10 +138,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
         break;
 
     case DLL_PROCESS_DETACH:
-        RPCRT4_destroy_all_protseqs();
-        RPCRT4_ServerFreeAllRegisteredAuthInfo();
-        DeleteCriticalSection(&uuid_cs);
-        DeleteCriticalSection(&threaddata_cs);
+        if (!lpvReserved) /* do nothing if process is shutting down */
+        {
+            RPCRT4_destroy_all_protseqs();
+            RPCRT4_ServerFreeAllRegisteredAuthInfo();
+            DeleteCriticalSection(&uuid_cs);
+            DeleteCriticalSection(&threaddata_cs);
+        }
         break;
     }
 
-- 
1.7.9.1


More information about the wine-patches mailing list