Skip to content

Commit 4bd646f

Browse files
author
Mike McLaughlin
authored
Backport "Fix incomplete dumps generated by createdump (#49468)" (#49512)
The core dump generated for a app that has large GC heaps (>4GB) are don't contain all the memory needed in process. This is because of a 32bit size value overflow; changed to size_t. Multiple customers have reported this problem in 3.1 and 5.0. Issue: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1277488?src=WorkItemMention&src-action=artifact_link and dotnet/diagnostics#1780
1 parent c4cea34 commit 4bd646f

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/coreclr/src/debug/createdump/createdumpunix.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ CreateDump(const char* dumpPathTemplate, int pid, const char* dumpType, MINIDUMP
4545
}
4646
if (!dumpWriter.WriteDump())
4747
{
48+
fprintf(stderr, "Writing dump FAILED\n");
4849
goto exit;
4950
}
5051
result = true;

src/coreclr/src/debug/createdump/dumpwriter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,24 +203,24 @@ DumpWriter::WriteDump()
203203
// Only write the regions that are backed by memory
204204
if (memoryRegion.IsBackedByMemory())
205205
{
206-
uint32_t size = memoryRegion.Size();
207206
uint64_t address = memoryRegion.StartAddress();
207+
size_t size = memoryRegion.Size();
208208
total += size;
209209

210210
while (size > 0)
211211
{
212-
uint32_t bytesToRead = std::min(size, (uint32_t)sizeof(m_tempBuffer));
212+
size_t bytesToRead = std::min(size, sizeof(m_tempBuffer));
213213
size_t read = 0;
214214

215215
if (!m_crashInfo.ReadProcessMemory((void*)address, m_tempBuffer, bytesToRead, &read)) {
216-
fprintf(stderr, "ReadProcessMemory(%" PRIA PRIx64 ", %08x) FAILED\n", address, bytesToRead);
216+
fprintf(stderr, "ReadProcessMemory(%" PRIA PRIx64 ", %08zx) FAILED\n", address, bytesToRead);
217217
return false;
218218
}
219219

220220
// This can happen if the target process dies before createdump is finished
221221
if (read == 0) {
222-
TRACE("ReadProcessMemory(%" PRIA PRIx64 ", %08x) return 0 bytes read\n", address, bytesToRead);
223-
break;
222+
fprintf(stderr, "ReadProcessMemory(%" PRIA PRIx64 ", %08zx) returned 0 bytes read\n", address, bytesToRead);
223+
return false;
224224
}
225225

226226
if (!WriteData(m_tempBuffer, read)) {

0 commit comments

Comments
 (0)