Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panicking in Drop of thread_local gives fatal runtime error #78277

Closed
m-ou-se opened this issue Oct 23, 2020 · 1 comment
Closed

Panicking in Drop of thread_local gives fatal runtime error #78277

m-ou-se opened this issue Oct 23, 2020 · 1 comment
Labels
A-destructors Area: Destructors (`Drop`, …) A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Oct 23, 2020

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
@m-ou-se m-ou-se added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` labels Oct 23, 2020
@m-ou-se m-ou-se self-assigned this Oct 23, 2020
@jonas-schievink jonas-schievink added the A-destructors Area: Destructors (`Drop`, …) label Oct 23, 2020
@m-ou-se m-ou-se changed the title Panicking in Drop of thread_local abort()s in #[test] Panicking in Drop of thread_local gives fatal runtime error Oct 26, 2020
@m-ou-se
Copy link
Member Author

m-ou-se commented Oct 26, 2020

Closing as duplicate of #24479.

@m-ou-se m-ou-se removed their assignment Oct 26, 2020
@m-ou-se m-ou-se removed the A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` label Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-destructors Area: Destructors (`Drop`, …) A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants