Open
Description
As I'm learning the language from a book ("The Complete Rust Programming Reference Guide" p. 229-230), and was executing the panic!
macro in a multi-thread environment, I've noticed the unwinding from the book is different from the one I've got where the one I've got is not informative or helpful, and seems wrong where the one in book seems to be OK.
Code
I tried this code:
// panic_unwinding.rs
use std::thread;
fn alice() -> thread::JoinHandle<()> {
thread::spawn(move || {
bob();
})
}
fn bob() {
malice();
}
fn malice() {
panic!("malice is panicking!");
}
fn main() {
let child = alice();
let _ = child.join();
bob();
println!("This is unreachable code");
}
I expected the backtrace to include the function names as they were called, all the way from the entry point of the threads.
Instead, all functions were named the same:
(env: RUST_BACKTRACE=1
)
thread '<unnamed>' panicked at 'malice is panicking!', .\panic_unwinding.rs:16:5
stack backtrace:
0: std::panicking::begin_panic
1: panic_unwinding::alice::{{closure}}
2: panic_unwinding::alice::{{closure}}
3: panic_unwinding::alice::{{closure}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'malice is panicking!', .\panic_unwinding.rs:16:5
stack backtrace:
0: std::panicking::begin_panic
1: panic_unwinding::alice::{{closure}}
2: panic_unwinding::alice::{{closure}}
3: panic_unwinding::alice::{{closure}}
4: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Version it worked on
I don't know from when is the regression. The book is using an old version of Rust: 1.32.0
Version with regression
I use the most current version: Rust 1.47.0
rustc --version --verbose
:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-pc-windows-msvc
release: 1.47.0
LLVM version: 11.0
Metadata
Metadata
Assignees
Labels
Area: Debugging information in compiled programs (DWARF, PDB, etc.)Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsCategory: This is a bug.Call for participation: Help is requested to fix this issue.Operating system: WindowsToolchain: MSVC, Operating system: WindowsMedium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.