Skip to content

Commit

Permalink
fix: Skip over low_pc sentinels instead of erroring (#590)
Browse files Browse the repository at this point in the history
Some compilers/linkers may use u64::MAX(-1) for the low_pc to indicate deleted / dead code functions. We should just skip over these instead of erroring out hard.
  • Loading branch information
Swatinem committed Jun 7, 2022
1 parent b736c22 commit d7b2ee0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions symbolic-debuginfo/src/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,18 @@ impl<'d, 'a> DwarfUnit<'d, 'a> {
};

if low_pc == high_pc {
// most likely low_pc == high_pc means the DIE should be ignored.
// Most likely low_pc == high_pc means the DIE should be ignored.
// https://sourceware.org/ml/gdb-patches/2011-03/msg00739.html
return Ok(tuple);
}

if low_pc == u64::MAX || low_pc == u64::MAX - 1 {
// Similarly, u64::MAX/u64::MAX-1 may be used to indicate deleted code.
// See https://reviews.llvm.org/D59553
return Ok(tuple);
}

if low_pc > high_pc {
// TODO: consider swallowing errors here?
return Err(DwarfErrorKind::InvertedFunctionRange.into());
}

Expand Down Expand Up @@ -805,7 +810,7 @@ impl<'d, 'a> DwarfUnit<'d, 'a> {
continue;
}

// In WASM files emitted by emscripted, we have observed a variety of broken ranges.
// In WASM files emitted by emscripten, we have observed a variety of broken ranges.
// One of these cases also involves ranges which are not being sorted, resulting in
// arithmetic underflow calculating `function_size` (in debug builds). Sorting the ranges
// should avoid this problem.
Expand Down

0 comments on commit d7b2ee0

Please sign in to comment.