Skip to content

Commit

Permalink
Auto merge of #40684 - alexcrichton:another-bet-anext, r=brson
Browse files Browse the repository at this point in the history
[beta] std: Back out backtrace pruning logic on beta

It was discovered #40264 that this backtrace pruning logic is a little too
aggressive, so while we figure how out to handle #40264 this commit backs out
the changes on beta to prune frames. Note that other cosmetic changes, such as
better path printing and such remain.
  • Loading branch information
bors committed Mar 27, 2017
2 parents b7c2766 + 7573111 commit 646873b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 81 deletions.
19 changes: 18 additions & 1 deletion src/ci/docker/emscripten/build-emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,24 @@ exit 1
}

curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \
tar xzf -
tar xzf -

# Some versions of the EMSDK archive have their contents in .emsdk-portable
# and others in emsdk_portable. Make sure the EMSDK ends up in a fixed path.
if [ -d emsdk-portable ]; then
mv emsdk-portable emsdk_portable
fi

if [ ! -d emsdk_portable ]; then
echo "ERROR: Invalid emsdk archive. Dumping working directory." >&2
ls -l
exit 1
fi

# Some versions of the EMSDK set the permissions of the root directory to
# 0700. Ensure the directory is readable by all users.
chmod 755 emsdk_portable

source emsdk_portable/emsdk_env.sh
hide_output emsdk update
hide_output emsdk install --build=Release sdk-tag-1.37.1-32bit
Expand Down
84 changes: 4 additions & 80 deletions src/libstd/sys_common/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,87 +93,11 @@ fn _print(w: &mut Write, format: PrintFormat) -> io::Result<()> {
Ok(())
}

fn filter_frames(frames: &[Frame],
format: PrintFormat,
context: &BacktraceContext) -> (usize, usize)
fn filter_frames(_frames: &[Frame],
_format: PrintFormat,
_context: &BacktraceContext) -> (usize, usize)
{
if format == PrintFormat::Full {
return (0, 0);
}

// We want to filter out frames with some prefixes
// from both top and bottom of the call stack.
static BAD_PREFIXES_TOP: &'static [&'static str] = &[
"_ZN3std3sys3imp9backtrace",
"ZN3std3sys3imp9backtrace",
"std::sys::imp::backtrace",
"_ZN3std10sys_common9backtrace",
"ZN3std10sys_common9backtrace",
"std::sys_common::backtrace",
"_ZN3std9panicking",
"ZN3std9panicking",
"std::panicking",
"_ZN4core9panicking",
"ZN4core9panicking",
"core::panicking",
"_ZN4core6result13unwrap_failed",
"ZN4core6result13unwrap_failed",
"core::result::unwrap_failed",
"rust_begin_unwind",
"_ZN4drop",
"mingw_set_invalid_parameter_handler",
];
static BAD_PREFIXES_BOTTOM: &'static [&'static str] = &[
"_ZN3std9panicking",
"ZN3std9panicking",
"std::panicking",
"_ZN3std5panic",
"ZN3std5panic",
"std::panic",
"_ZN4core9panicking",
"ZN4core9panicking",
"core::panicking",
"_ZN3std2rt10lang_start",
"ZN3std2rt10lang_start",
"std::rt::lang_start",
"panic_unwind::__rust_maybe_catch_panic",
"__rust_maybe_catch_panic",
"_rust_maybe_catch_panic",
"__libc_start_main",
"__rust_try",
"_start",
"main",
"BaseThreadInitThunk",
"RtlInitializeExceptionChain",
"__scrt_common_main_seh",
"_ZN4drop",
"mingw_set_invalid_parameter_handler",
];

let is_good_frame = |frame: Frame, bad_prefixes: &[&str]| {
resolve_symname(frame, |symname| {
if let Some(mangled_symbol_name) = symname {
if !bad_prefixes.iter().any(|s| mangled_symbol_name.starts_with(s)) {
return Ok(())
}
}
Err(io::Error::from(io::ErrorKind::Other))
}, context).is_ok()
};

let skipped_before = frames.iter().position(|frame| {
is_good_frame(*frame, BAD_PREFIXES_TOP)
}).unwrap_or(frames.len());
let skipped_after = frames[skipped_before..].iter().rev().position(|frame| {
is_good_frame(*frame, BAD_PREFIXES_BOTTOM)
}).unwrap_or(frames.len() - skipped_before);

if skipped_before + skipped_after == frames.len() {
// Avoid showing completely empty backtraces
return (0, 0);
}

(skipped_before, skipped_after)
(0, 0)
}

/// Controls how the backtrace should be formated.
Expand Down

0 comments on commit 646873b

Please sign in to comment.