Open
Description
Given this file foo.rs
:
fn main() {
panic!();
}
A short backtrace for this panic would ideally include only std::panicking::begin_panic
and foo::main
. And, indeed, the implementing PR has a test for this output:
However, this is how the backtrace actually looks with various flags:
rustc
(no flags; debug mode)
0: std::panicking::begin_panic
1: foo::main
2: core::ops::function::FnOnce::call_once
rustc -O
(release mode)
0: std::panicking::begin_panic
1: foo::main
rustc -O -C debuginfo=1
(release mode with debuginfo)
0: std::panicking::begin_panic
at ./.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:505
1: foo::main
at ./foo.rs:2
2: core::ops::function::FnOnce::call_once
at ./.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
So I think the __rust_begin_short_backtrace
implementation needs to account for this extra stack frame when it isn't optimized out by release mode. The test mentioned above only passes because it's compiled with -O
:
I tested this on 1.47.0 stable and a nightly version:
rustc --version --verbose
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0
rustc 1.49.0-nightly (91a79fb29 2020-10-07)
binary: rustc
commit-hash: 91a79fb29ac78d057d04dbe86be13d5dcc64309a
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0