Skip to content

Commit

Permalink
Fix createdump crash on alpine 3.12 and above. (#56272)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mikem8361 authored Jul 25, 2021
1 parent ce3e00b commit 9586375
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/coreclr/debug/createdump/crashinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,9 @@ bool
CrashInfo::UnwindAllThreads(IXCLRDataProcess* pClrDataProcess)
{
ReleaseHolder<ISOSDacInterface> pSos = nullptr;
pClrDataProcess->QueryInterface(__uuidof(ISOSDacInterface), (void**)&pSos);

if (pClrDataProcess != nullptr) {
pClrDataProcess->QueryInterface(__uuidof(ISOSDacInterface), (void**)&pSos);
}
// For each native and managed thread
for (ThreadInfo* thread : m_threads)
{
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/debug/createdump/crashinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ class CrashInfo : public ICLRDataEnumMemoryRegionsCallback,
inline const std::string& Name() const { return m_name; }
inline const ModuleInfo* MainModule() const { return m_mainModule; }

inline const std::vector<ThreadInfo*> Threads() const { return m_threads; }
inline const std::set<MemoryRegion> ModuleMappings() const { return m_moduleMappings; }
inline const std::set<MemoryRegion> OtherMappings() const { return m_otherMappings; }
inline const std::set<MemoryRegion> MemoryRegions() const { return m_memoryRegions; }
inline const std::vector<ThreadInfo*>& Threads() const { return m_threads; }
inline const std::set<MemoryRegion>& ModuleMappings() const { return m_moduleMappings; }
inline const std::set<MemoryRegion>& OtherMappings() const { return m_otherMappings; }
inline const std::set<MemoryRegion>& MemoryRegions() const { return m_memoryRegions; }
#ifndef __APPLE__
inline const std::vector<elf_aux_entry> AuxvEntries() const { return m_auxvEntries; }
inline const std::vector<elf_aux_entry>& AuxvEntries() const { return m_auxvEntries; }
inline size_t GetAuxvSize() const { return m_auxvEntries.size() * sizeof(elf_aux_entry); }
#endif

Expand Down

0 comments on commit 9586375

Please sign in to comment.