Avoid AV when `EventPipeSession::m_pFile` is nullptr. (dotnet/coreclr#25845)
authorJosé Rivero <jorive@microsoft.com>
Tue, 23 Jul 2019 22:38:49 +0000 (15:38 -0700)
committerGitHub <noreply@github.com>
Tue, 23 Jul 2019 22:38:49 +0000 (15:38 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/5c5a8969b5dafc5b8afe195ab8f96ea0ad617e77

src/coreclr/src/vm/eventpipesession.cpp

index 6068c440ad1bbe5f6acd197b2322be98448b3df3..5a47bef1fb268ca90d4016ada33f04a7d2a0c53a 100644 (file)
@@ -184,7 +184,7 @@ DWORD WINAPI EventPipeSession::ThreadProc(void *args)
                     // No events were available, sleep until more are available
                     waitEvent->Wait(INFINITE, FALSE);
                 }
-                
+
                 // Wait until it's time to sample again.
                 PlatformSleep();
             }
@@ -224,6 +224,7 @@ void EventPipeSession::CreateIpcStreamingThread()
         THROWS;
         GC_TRIGGERS;
         MODE_PREEMPTIVE;
+        PRECONDITION(m_SessionType == EventPipeSessionType::IpcStream);
         PRECONDITION(EventPipe::IsLockOwnedByCurrentThread());
     }
     CONTRACTL_END;
@@ -377,7 +378,8 @@ void EventPipeSession::StartStreaming()
     }
     CONTRACTL_END;
 
-    m_pFile->InitializeFile();
+    if (m_pFile != nullptr)
+        m_pFile->InitializeFile();
 
     if (m_SessionType == EventPipeSessionType::IpcStream)
         CreateIpcStreamingThread();