Fix pipe file cleanup in /tmp directory.
authorMike McLaughlin <mikem@microsoft.com>
Fri, 11 Dec 2015 23:31:33 +0000 (15:31 -0800)
committerMike McLaughlin <mikem@microsoft.com>
Sat, 12 Dec 2015 00:09:13 +0000 (16:09 -0800)
The debugger/transport shutdown was not being called because we don't emulate
coreclr's DllMain DLL_PROCESS_DETACH callbacks. Adding the DLL_PROCESS_DETACH
DllMain callbacks will potentially crash deadlocks and other problems.  Added the
debugger terminate/shutdown call to EEShutDown's first phase.

src/debug/shared/dbgtransportsession.cpp
src/vm/ceemain.cpp

index ad9931f..2b17f6d 100644 (file)
@@ -160,7 +160,7 @@ void DbgTransportSession::Shutdown()
             SessionState ePreviousState = m_eState;
             m_eState = SS_Closed;
 
-            if ((ePreviousState != SS_Opening_NC) && (ePreviousState != SS_Resync_NC) && (ePreviousState != SS_Closed))
+            if (ePreviousState != SS_Closed)
             {
                 m_pipe.Disconnect();
             }
@@ -171,10 +171,6 @@ void DbgTransportSession::Shutdown()
         // Signal the m_hSessionOpenEvent now to quickly error out any callers of WaitForSessionToOpen().
         SetEvent(m_hSessionOpenEvent);
 #endif // RIGHT_SIDE_COMPILE
-
-        // Now let the transport thread shut itself down cleanly. This will take care of emptying the send queue
-        // as well.
-        WaitForSingleObject(m_hTransportThread, INFINITE);
     }
 
     // No other threads are now using session resources. We're free to deallocate them as we wish (if they
index a4db91c..100ee70 100644 (file)
@@ -1952,6 +1952,12 @@ void STDMETHODCALLTYPE EEShutDownHelper(BOOL fIsDllUnloading)
         
         FastInterlockExchange((LONG*)&g_fForbidEnterEE, TRUE);
 
+#if defined(DEBUGGING_SUPPORTED) && defined(FEATURE_PAL)
+        // Terminate the debugging services in the first phase for PAL based platforms
+        // because EEDllMain's DLL_PROCESS_DETACH is NOT going to be called.
+        TerminateDebugger();
+#endif // DEBUGGING_SUPPORTED && FEATURE_PAL
+
         if (g_fProcessDetach)
         {
             ThreadStore::TrapReturningThreads(TRUE);