Skip to content

regression: panic! and RUST_BACKTRACE=1 Show Wrong & Non-Informative Function Names when Unwinding #78713

Open
@DK26

Description

@DK26

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

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.O-windowsOperating system: WindowsO-windows-msvcToolchain: MSVC, Operating system: WindowsP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions