Move EventPipeEventSource deletion to a better place (#24901)
authorSung Yoon Whang <suwhang@microsoft.com>
Sat, 1 Jun 2019 00:17:12 +0000 (17:17 -0700)
committerGitHub <noreply@github.com>
Sat, 1 Jun 2019 00:17:12 +0000 (17:17 -0700)
* Move EventPipeEventSource deletion to a better place

* typo

src/vm/eventpipe.cpp

index dea3b1e..0458be8 100644 (file)
@@ -259,6 +259,11 @@ void EventPipe::Shutdown()
     EX_CATCH {}
     EX_END_CATCH(SwallowAllExceptions);
 
+    // Remove EventPipeEventSource first since it tries to use the data structures that we remove below.
+    // We need to do this after disabling sessions since those try to write to EventPipeEventSource.
+    delete s_pEventSource;
+    s_pEventSource = nullptr;
+
     EventPipeConfiguration *pConfig = s_pConfig;
     EventPipeSessions *pSessions = s_pSessions;
 
@@ -271,8 +276,6 @@ void EventPipe::Shutdown()
     // Free resources.
     delete pConfig;
     delete pSessions;
-    delete s_pEventSource;
-    s_pEventSource = nullptr;
 }
 
 EventPipeSessionID EventPipe::Enable(