Fix Segfault in PerfInfo Image Logging (#26910)
authorBrian Robbins <brianrob@microsoft.com>
Tue, 15 Oct 2019 18:23:19 +0000 (11:23 -0700)
committerStephen Toub <stoub@microsoft.com>
Mon, 21 Oct 2019 02:45:03 +0000 (22:45 -0400)
src/vm/perfinfo.cpp

index 7075137..3667503 100644 (file)
@@ -41,8 +41,21 @@ void PerfInfo::LogImage(PEFile* pFile, WCHAR* guid)
 
     SString value;
     const SString& path = pFile->GetPath();
-    PEImageLayout *pLoadedLayout = pFile->GetLoaded();
-    SIZE_T baseAddr = (SIZE_T)pLoadedLayout->GetBase();
+    if (path.IsEmpty())
+    {
+        return;
+    }
+
+    SIZE_T baseAddr = 0;
+    if (pFile->IsILImageReadyToRun())
+    {
+        PEImageLayout *pLoadedLayout = pFile->GetLoaded();
+        if (pLoadedLayout)
+        {
+            baseAddr = (SIZE_T)pLoadedLayout->GetBase();
+        }
+    }
+
     value.Printf("%S%c%S%c%p", path.GetUnicode(), sDelimiter, guid, sDelimiter, baseAddr);
 
     SString command;