diff options
author | Sung Yoon Whang <suwhang@microsoft.com> | 2019-08-16 16:31:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-16 16:31:01 -0700 |
commit | c4df438b025beeb73b8d415f479eeef2020f5e91 (patch) | |
tree | 469dfc0bdd6eddb3f7017c3b3a04387f444f7f1a | |
parent | cca2f13d35a93b7b545868843dffa261949c084b (diff) | |
download | coreclr-c4df438b025beeb73b8d415f479eeef2020f5e91.tar.gz coreclr-c4df438b025beeb73b8d415f479eeef2020f5e91.tar.bz2 coreclr-c4df438b025beeb73b8d415f479eeef2020f5e91.zip |
Clean up diagnosticserver socket on unexpected shutdown (#25976) (#26190)
* Clean up diagnosticserver socket/pipe on shutdown
* Refactor dbg transport pipe cleanup to be registered as signal handler from the vm side
* cleanup dead code
* Remove more dead code and fix windows builds
* Moving some ifdefs around
-rw-r--r-- | src/debug/ee/debugger.cpp | 22 | ||||
-rw-r--r-- | src/debug/ee/debugger.h | 2 | ||||
-rw-r--r-- | src/vm/ceemain.cpp | 30 | ||||
-rw-r--r-- | src/vm/dbginterface.h | 3 |
4 files changed, 45 insertions, 12 deletions
diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp index 0299cfef12..a5e081c02e 100644 --- a/src/debug/ee/debugger.cpp +++ b/src/debug/ee/debugger.cpp @@ -890,15 +890,6 @@ ShutdownTransport() g_pDbgTransport = NULL; } } - -void -AbortTransport() -{ - if (g_pDbgTransport != NULL) - { - g_pDbgTransport->AbortConnection(); - } -} #endif // FEATURE_DBGIPC_TRANSPORT_VM @@ -1895,6 +1886,16 @@ void NotifyDebuggerOfStartup() #endif // !FEATURE_PAL +void Debugger::CleanupTransportSocket(void) +{ +#if defined(FEATURE_PAL) && defined(FEATURE_DBGIPC_TRANSPORT_VM) + if (g_pDbgTransport != NULL) + { + g_pDbgTransport->AbortConnection(); + } +#endif // FEATURE_PAL && FEATURE_DBGIPC_TRANSPORT_VM +} + //--------------------------------------------------------------------------------------- // // Initialize Left-Side debugger object @@ -2047,9 +2048,6 @@ HRESULT Debugger::Startup(void) ShutdownTransport(); ThrowHR(hr); } - #ifdef FEATURE_PAL - PAL_SetShutdownCallback(AbortTransport); - #endif // FEATURE_PAL #endif // FEATURE_DBGIPC_TRANSPORT_VM RaiseStartupNotification(); diff --git a/src/debug/ee/debugger.h b/src/debug/ee/debugger.h index 67180c0a27..dc36784f5e 100644 --- a/src/debug/ee/debugger.h +++ b/src/debug/ee/debugger.h @@ -1852,6 +1852,8 @@ public: HRESULT StartupPhase2(Thread * pThread); + void CleanupTransportSocket(); + void InitializeLazyDataIfNecessary(); void LazyInit(); // will throw diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp index b91fe714e4..508693767f 100644 --- a/src/vm/ceemain.cpp +++ b/src/vm/ceemain.cpp @@ -596,6 +596,31 @@ do { \ #define IfFailGoLog(EXPR) IfFailGotoLog(EXPR, ErrExit) #endif + +#ifndef CROSSGEN_COMPILE +#ifdef FEATURE_PAL +void EESocketCleanupHelper() +{ + CONTRACTL + { + GC_NOTRIGGER; + MODE_ANY; + } CONTRACTL_END; + + // Close the debugger transport socket first + if (g_pDebugInterface != NULL) + { + g_pDebugInterface->CleanupTransportSocket(); + } + + // Close the diagnostic server socket. +#ifdef FEATURE_PERFTRACING + DiagnosticServer::Shutdown(); +#endif // FEATURE_PERFTRACING +} +#endif // FEATURE_PAL +#endif // CROSSGEN_COMPILE + void EEStartupHelper(COINITIEE fFlags) { CONTRACTL @@ -653,8 +678,13 @@ void EEStartupHelper(COINITIEE fFlags) #ifdef FEATURE_PERFTRACING // Initialize the event pipe. EventPipe::Initialize(); + #endif // FEATURE_PERFTRACING +#ifdef FEATURE_PAL + PAL_SetShutdownCallback(EESocketCleanupHelper); +#endif // FEATURE_PAL + #ifdef FEATURE_GDBJIT // Initialize gdbjit NotifyGdb::Initialize(); diff --git a/src/vm/dbginterface.h b/src/vm/dbginterface.h index ebf85e397a..96157bb6b9 100644 --- a/src/vm/dbginterface.h +++ b/src/vm/dbginterface.h @@ -399,6 +399,9 @@ public: virtual LONG FirstChanceSuspendHijackWorker(PCONTEXT pContext, PEXCEPTION_RECORD pExceptionRecord) = 0; #endif + // Helper method for cleaning up transport socket + virtual void CleanupTransportSocket(void) = 0; + #endif // #ifndef DACCESS_COMPILE #ifdef DACCESS_COMPILE |