Skip to content

miri: ub inside safe code with feature thread_local #96191

Closed
rust-lang/miri
#2074
@matthiaskrgr

Description

@matthiaskrgr

I tried this code:

// Regression test for https://github.com/rust-lang/rust/issues/70673.

// run-pass

#![feature(thread_local)]

#[thread_local]
static A: &u8 = &42;

fn main() {
    dbg!(*A);
}

Miri reports:

[src/main.rs:11] *A = 42
error: Undefined Behavior: deallocating immutable allocation alloc1301
  |
  = note: deallocating immutable allocation alloc1301
  = note: (no span available)
  = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
  = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
rustc 1.62.0-nightly (ec77f2524 2022-04-17)
binary: rustc
commit-hash: ec77f252434a532fdb5699ae4f21a3072d211edd
commit-date: 2022-04-17
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-miriArea: The miri toolC-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