Skip to content

Commit

Permalink
Fix createdump segfault writing crash report json (dotnet#56437)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikem8361 authored Jul 28, 2021
1 parent a6b9a63 commit c0cad5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/coreclr/debug/createdump/crashinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ CrashInfo::CrashInfo(pid_t pid, bool gatherFrames, pid_t crashThread, uint32_t s
m_gatherFrames(gatherFrames),
m_crashThread(crashThread),
m_signal(signal),
m_moduleInfos(&ModuleInfoCompare)
m_moduleInfos(&ModuleInfoCompare),
m_mainModule(nullptr)
{
g_crashInfo = this;
#ifdef __APPLE__
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/debug/createdump/crashreportwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ CrashReportWriter::WriteCrashReport()
WriteValue("version", version.c_str());
CloseObject(); // configuration

// The main module was saved away in the crash info
if (m_crashInfo.MainModule()->BaseAddress() != 0)
// The main module (if one) was saved away in the crash info
const ModuleInfo* mainModule = m_crashInfo.MainModule();
if (mainModule != nullptr && mainModule->BaseAddress() != 0)
{
WriteValue("process_name", GetFileName(m_crashInfo.MainModule()->ModuleName()).c_str());
WriteValue("process_name", GetFileName(mainModule->ModuleName()).c_str());
}

const char* exceptionType = nullptr;
OpenArray("threads");
for (const ThreadInfo* thread : m_crashInfo.Threads())
Expand Down

0 comments on commit c0cad5f

Please sign in to comment.