Skip to content

Commit 9586375

Browse files
author
Mike McLaughlin
authored
Fix createdump crash on alpine 3.12 and above. (#56272)
Finally hit an existing problem in createdump (since 2.1) where the std::set<MemoryRegions> in ThreadInfo::GetThreadStack() where it is calling CrashInfo::SearchMemoryRegions with m_crashInfo.OtherMappings() which returns a copy of the set of MemoryRegions instead of a reference. On alpine 3.12 musl, this set copy is freed right away when it goes out of scope as soon as SearchMemoryRegions returns. On any other Linux distro and MacOS the set doesn't get freed/invalidated as soon. Return references to the threads and memory region sets in the CrashInfo functions.
1 parent ce3e00b commit 9586375

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/coreclr/debug/createdump/crashinfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,9 @@ bool
361361
CrashInfo::UnwindAllThreads(IXCLRDataProcess* pClrDataProcess)
362362
{
363363
ReleaseHolder<ISOSDacInterface> pSos = nullptr;
364-
pClrDataProcess->QueryInterface(__uuidof(ISOSDacInterface), (void**)&pSos);
365-
364+
if (pClrDataProcess != nullptr) {
365+
pClrDataProcess->QueryInterface(__uuidof(ISOSDacInterface), (void**)&pSos);
366+
}
366367
// For each native and managed thread
367368
for (ThreadInfo* thread : m_threads)
368369
{

src/coreclr/debug/createdump/crashinfo.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ class CrashInfo : public ICLRDataEnumMemoryRegionsCallback,
106106
inline const std::string& Name() const { return m_name; }
107107
inline const ModuleInfo* MainModule() const { return m_mainModule; }
108108

109-
inline const std::vector<ThreadInfo*> Threads() const { return m_threads; }
110-
inline const std::set<MemoryRegion> ModuleMappings() const { return m_moduleMappings; }
111-
inline const std::set<MemoryRegion> OtherMappings() const { return m_otherMappings; }
112-
inline const std::set<MemoryRegion> MemoryRegions() const { return m_memoryRegions; }
109+
inline const std::vector<ThreadInfo*>& Threads() const { return m_threads; }
110+
inline const std::set<MemoryRegion>& ModuleMappings() const { return m_moduleMappings; }
111+
inline const std::set<MemoryRegion>& OtherMappings() const { return m_otherMappings; }
112+
inline const std::set<MemoryRegion>& MemoryRegions() const { return m_memoryRegions; }
113113
#ifndef __APPLE__
114-
inline const std::vector<elf_aux_entry> AuxvEntries() const { return m_auxvEntries; }
114+
inline const std::vector<elf_aux_entry>& AuxvEntries() const { return m_auxvEntries; }
115115
inline size_t GetAuxvSize() const { return m_auxvEntries.size() * sizeof(elf_aux_entry); }
116116
#endif
117117

0 commit comments

Comments
 (0)