From 6e5bf066aced2920b17e17362a98f96d34ac56fe Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Tue, 17 Sep 2024 16:47:37 +0200 Subject: [PATCH] fix(cfi): Skip u64::MAX FDEs when converting DWARF (#868) We have seen FDEs with an initial address of u64::MAX in user-provided DWARF files. Such FDEs will invariably fail to process because of either an address overflow error in gimli or an underflow in the length calculation in line 756. Therefore, we skip them immediately so we don't abort the processing of the entire file. --- CHANGELOG.md | 3 +++ symbolic-cfi/src/lib.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eed8a25..bc4c841c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +**Fixes** +- symbolic-cfi: Skip invalid FDEs when converting DWARF to Breakpad CFI ([#868](https://github.com/getsentry/symbolic/pull/868)) + **Internal**: - Removed `dmsort` dependency and replaced uses with stable std sorts. ([#869](https://github.com/getsentry/symbolic/pull/869)) diff --git a/symbolic-cfi/src/lib.rs b/symbolic-cfi/src/lib.rs index faf64097..7bc69b7a 100644 --- a/symbolic-cfi/src/lib.rs +++ b/symbolic-cfi/src/lib.rs @@ -717,6 +717,15 @@ impl AsciiCfiWriter { R: Reader + Eq, U: UnwindSection, { + // We have seen FDEs with an initial address of `u64::MAX` in user-provided + // DWARF files. Such FDEs will invariably fail to process because of either + // an address overflow error in `gimli` or an underflow in the `length` + // calculation below. Therefore, we skip them immediately so we don't abort + // the processing of the entire file. + if fde.initial_address() == u64::MAX { + return Ok(()); + } + // Retrieves the register that specifies the return address. We need to assign a special // format to this register for Breakpad. let ra = fde.cie().return_address_register();