Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix createdump segfault writing crash report json #56437

Merged
1 commit merged into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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