From 08bd844599bf04c71707e8f59a8013a941264695 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Fri, 28 Jan 2022 16:49:10 -0800 Subject: [PATCH] Fix corner cases on Windows dump_syms - don't do iter decrement when the map empty. - add dummy file with id equals to 0 to represent unknown file. Change-Id: I3fe55a459c9fa835bbe0c4272e4ac12b1150c034 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3425732 Reviewed-by: Joshua Peraza --- src/common/windows/pdb_source_line_writer.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc index ca0c6a39..25a1ca05 100644 --- a/src/common/windows/pdb_source_line_writer.cc +++ b/src/common/windows/pdb_source_line_writer.cc @@ -343,8 +343,10 @@ void PDBSourceLineWriter::Lines::AddLine(const Line& line) { do { auto iter = line_map_.lower_bound(line.rva); if (iter == line_map_.end()) { - --iter; - intercept(iter->second); + if (!line_map_.empty()) { + --iter; + intercept(iter->second); + } break; } is_intercept = false; @@ -570,6 +572,10 @@ bool PDBSourceLineWriter::PrintSourceFiles() { return false; } + // Print a dummy file with id equals 0 to represent unknown file, because + // inline records might have unknown call site. + fwprintf(output_, L"FILE %d unknown file\n", 0); + CComPtr compiland; ULONG count; while (SUCCEEDED(compilands->Next(1, &compiland, &count)) && count == 1) {