From cd0cc95e2794375c463a69833b1ccc9cc96d597c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 1 Jul 2020 11:27:54 -0700 Subject: DWARF: Ignore debug_loc spans that are invalid (#2939) An (x, y) span is updated to some (q, r) in the new binary. If q > r then the span is no longer valid - the optimizer has reordered things too much. It's possible this could be flipped, but I'm not certain. It seems safer to just omit these, which are very rare (I only see this on some larger testcases in the emscripten test suite). --- src/wasm/wasm-debug.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp index 112c805d8..c8e8c07a4 100644 --- a/src/wasm/wasm-debug.cpp +++ b/src/wasm/wasm-debug.cpp @@ -992,8 +992,9 @@ static void updateLoc(llvm::DWARFYAML::Data& yaml, // a new address for it. newStart = locationUpdater.getNewStart(loc.Start + oldBase); newEnd = locationUpdater.getNewEnd(loc.End + oldBase); - if (newStart == 0 || newEnd == 0) { - // This part of the loc no longer has a mapping, so we must ignore it. + if (newStart == 0 || newEnd == 0 || newStart > newEnd) { + // This part of the loc no longer has a mapping, or after the mapping + // it is no longer a proper span, so we must ignore it. newStart = newEnd = IGNOREABLE_LOCATION; } else { // We picked a new base that ensures it is smaller than the values we -- cgit v1.2.3