Skip to content

Panicking in Drop of thread_local gives fatal runtime error #78277

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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions