Repository navigation
Write to #[thread_local] is not respected #54901
Copy link
Copy link
Closed
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Description
Activity
Ah, apparently this is missing a
mut. Withmutthe behavior is correct. We need to make sure mutating a thread_local static that does not havemutdoes not compile.#![feature(thread_local)] #[thread_local] static mut S: &str = "before"; fn set_s() { unsafe { S = "after" }; } fn main() { println!("{}", unsafe { S }); set_s(); println!("{}", unsafe { S }); }
$ cargo run --release before after
Reacted by Sander Maijers, mforsb, Taylor Cramer, scottmcm and Donato Sciarra- addedfixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
on Oct 12, 2018 cc @pnkfelix @nikomatsakis Did #55150 fix this by any chance?
It looks like this is fixed on nightly; I'm guessing #55150 is the reason. We probably should add some regression tests for the cases listed here.
- addedE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Nov 5, 2018 - added 6 commits that reference this issue
on Jan 15, 2019 - added a commit that references this issue
on Jan 18, 2019 - added a commit that references this issue
on Jan 18, 2019
Metadata
Metadata
Assignees
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
On rustc 1.31.0-nightly (b2d6ea9 2018-10-07) and x86_64-unknown-linux-gnu, we see the following surprising behavior:
In release mode it seems the write has not happened in the place that it should.
Mentioning thread_local tracking issue: rust-lang/rust#29594.