Skip to content

Panicking in Drop of thread_local gives fatal runtime error #78277

Closed
@m-ou-se

Description

@m-ou-se

This was uncovered in #75172 / #78227.

struct PanicInDrop;

impl Drop for PanicInDrop {
    fn drop(&mut self) { panic!("💥"); }
}

thread_local!(static X: PanicInDrop = PanicInDrop);

fn main() {
    X.with(|_| ());
}

This fails with:

thread 'main' panicked at '💥', src/main.rs:4:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-destructorsArea: Destructors (`Drop`, …)A-thread-localsArea: Thread local storage (TLS)C-bugCategory: This is a bug.T-libs-apiRelevant to the library API 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