Skip to content

Commit

Permalink
If CFI writing fails, print an error and continue.
Browse files Browse the repository at this point in the history
This restores the error handling from elf.rs from before
mozilla#433 . That PR changed it to
an unwrap because the PDB code was using unwrap.

old elf.rs: https://github.com/mozilla/dump_syms/blob/de7cc440533b794f85ca4e1f10e26d918330140d/src/linux/elf.rs#L464-L466
old pdb.rs: https://github.com/mozilla/dump_syms/blob/de7cc440533b794f85ca4e1f10e26d918330140d/src/windows/pdb.rs#L254

We encounter this error for libmozavutil.so on certain Linux debug builds,
see https://bugzilla.mozilla.org/show_bug.cgi?id=1783899#c6 .
  • Loading branch information
mstange committed Aug 11, 2022
1 parent ca37dd6 commit 516b666
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/object_info.rs
Expand Up @@ -3,6 +3,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use log::error;
use std::collections::btree_map;
use std::fmt::{Display, Formatter};
use std::io::Write;
Expand Down Expand Up @@ -75,14 +76,14 @@ fn get_stack_info(pdb: Option<&Object>, pe: Option<&Object>) -> String {
let mut buf = Vec::new();
let mut cfi_writer = AsciiCfiWriter::new(&mut buf);

match (pdb, pe) {
(_, Some(pe)) if pe.has_unwind_info() => {
cfi_writer.process(pe).unwrap();
}
(Some(pdb), _) if pdb.has_unwind_info() => {
cfi_writer.process(pdb).unwrap();
}
_ => {}
let result = match (pdb, pe) {
(_, Some(pe)) if pe.has_unwind_info() => cfi_writer.process(pe),
(Some(pdb), _) if pdb.has_unwind_info() => cfi_writer.process(pdb),
_ => Ok(()),
};

if let Err(e) = result {
error!("CFI: {:?}", e);
}

String::from_utf8(buf).unwrap()
Expand Down

0 comments on commit 516b666

Please sign in to comment.