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

STATUS_ACCESS_VIOLATION in unstable thread_local feature on windows-gnu #100917

Open
uselessgoddess opened this issue Aug 23, 2022 · 1 comment
Open
Labels
C-bug Category: This is a bug. F-thread_local `#![feature(thread_local)]` O-windows-gnu Toolchain: GNU, Operating system: Windows

Comments

@uselessgoddess
Copy link

I tried this code:

#![feature(thread_local)]

use std::cell::RefCell;
use std::mem::MaybeUninit;

#[thread_local]
static PLACE: RefCell<usize> = RefCell::new(0);

fn touch(x: usize) {
    *PLACE.borrow_mut() = x;
}

pub fn main() {
    touch(12);
}

But it breaks down inside RefCell:
error: process didn't exit successfully: 'target\debug\sandbox.exe' (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Debugger comes to here:
image

rustc 1.65.0-nightly (878aef79d 2022-08-20)
binary: rustc
commit-hash: 878aef79dcdf59d19bb8482202dc55e58ceb62ff
commit-date: 2022-08-20
host: x86_64-pc-windows-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

@uselessgoddess uselessgoddess added the C-bug Category: This is a bug. label Aug 23, 2022
@wesleywiser wesleywiser added O-windows-gnu Toolchain: GNU, Operating system: Windows F-thread_local `#![feature(thread_local)]` labels Aug 23, 2022
@mati865
Copy link
Contributor

mati865 commented Sep 24, 2022

Quoting myself from #102243 (comment):

[..] EmuTLS used by GCC is just too messed up and causes problems for all languages that use TLS.
I don't think it's possible to workaround this problem in Rust but FWIW windows-gnullvm targets that I added not so long ago are working perfectly fine with it (although they are not tested on CI): #94872 (files) This is because LLVM uses native Windows TLS by default which is not implemented in GCC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-thread_local `#![feature(thread_local)]` O-windows-gnu Toolchain: GNU, Operating system: Windows
Projects
None yet
Development

No branches or pull requests

3 participants