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

miri: ub inside safe code with feature thread_local #96191

Closed
matthiaskrgr opened this issue Apr 18, 2022 · 0 comments · Fixed by rust-lang/miri#2074
Closed

miri: ub inside safe code with feature thread_local #96191

matthiaskrgr opened this issue Apr 18, 2022 · 0 comments · Fixed by rust-lang/miri#2074
Labels
A-miri Area: The miri tool C-bug Category: This is a bug.

Comments

@matthiaskrgr
Copy link
Member

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
@matthiaskrgr matthiaskrgr added the C-bug Category: This is a bug. label Apr 18, 2022
@RalfJung RalfJung added the A-miri Area: The miri tool label Apr 18, 2022
@RalfJung RalfJung changed the title miri: ub inside safe code wifh feature thread_local miri: ub inside safe code with feature thread_local Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-miri Area: The miri tool C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants