Skip to content

#[thread_local] from windows DLLs gets duplicated by inlining. #44391

Open
@eddyb

Description

@eddyb

This is most likely responsible for the windows failures from #43931 when the __getit function, which may return a reference to a #[thread_local] static, was #[inline] (cc @alexcrichton):

// a.rs
#![crate_type = "dylib"]
#![feature(thread_local)]

#[thread_local]
static FOO: u32 = 25;

pub fn addr() -> *const u32 {
    &FOO
}

#[inline]
pub fn addr_inline() -> *const u32 {
    &FOO
}
// b.rs
extern crate a;

fn main() {
    assert_eq!(a::addr(), a::addr_inline());
}

Running b, on x64 MSVC (thanks, @bcata6!) results in:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `0x134cb61ace4`,
 right: `0x134cb6139c0`', b.rs:4:4

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-thread-localsArea: Thread local storage (TLS)C-bugCategory: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions