-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run many-seeds tests at least a few times on all tier 1 targets
- Loading branch information
Showing
2 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
//! Regression test for <https://github.com/rust-lang/rust/issues/123583>. | ||
use std::thread; | ||
|
||
pub(crate) fn with_thread_local() { | ||
fn with_thread_local1() { | ||
thread_local! { static X: Box<u8> = Box::new(0); } | ||
X.with(|_x| {}) | ||
} | ||
|
||
fn with_thread_local2() { | ||
thread_local! { static Y: Box<u8> = Box::new(0); } | ||
Y.with(|_y| {}) | ||
} | ||
|
||
fn main() { | ||
let j2 = thread::spawn(with_thread_local); | ||
with_thread_local(); | ||
j2.join().unwrap(); | ||
// Here we have two threads racing on initializing the thread-local and adding it to the global | ||
// dtor list (on targets that have such a list, i.e., targets without target_thread_local). | ||
let t = thread::spawn(with_thread_local1); | ||
with_thread_local1(); | ||
t.join().unwrap(); | ||
|
||
// Here we have one thread running the destructors racing with another thread initializing a | ||
// thread-local. The second thread adds a destructor that could be picked up by the first. | ||
let t = thread::spawn(|| { /* immediately just run destructors */ }); | ||
with_thread_local2(); // initialize thread-local | ||
t.join().unwrap(); | ||
} |