Skip to content

Double-panic when thread local drop eprintlns (only with stable 1.43.0) #71536

Closed
@vakaras

Description

@vakaras

The example below double-panics (segfaults) with stable 1.43.0, but I cannot see any reason why this should happen.

I am not sure whether this is already fixed or not because I could reproduce it only with the latest stable version of the Rust compiler, but not with nightly or beta. However, I could not find any related issue on the issue tracker, so decided to open a new one.

I tried this code (playground):

struct TestCell {}

impl Drop for TestCell {
    fn drop(&mut self) {
        eprintln!("Dropping")
    }
}

thread_local! {
    static A: TestCell = TestCell {};
}

fn main() {
    A.with(|_| {});
    eprintln!("Continue main.")
}

I expected the program to print the following as it does with nightly and beta versions of the compiler:

Continue main.
Dropping

Instead, I get the following output:

Continue main.
thread panicked while processing panic. aborting.
fish: “./test” terminated by signal SIGILL (Illegal instruction)

Meta

I can reproduce the bug only on the stable version of the compiler.

rustc --version --verbose:

rustc 1.43.0 (4fb7144ed 2020-04-20)
binary: rustc
commit-hash: 4fb7144ed159f94491249e86d5bbd033b5d60550
commit-date: 2020-04-20
host: x86_64-unknown-linux-gnu
release: 1.43.0
LLVM version: 9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions