Skip to content

Commit 10f34a6

Browse files
committed
run many-seeds tests at least a few times on all tier 1 targets
1 parent 95057c4 commit 10f34a6

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

ci/ci.sh

+11-7
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,18 @@ function run_tests_minimal {
128128
## Main Testing Logic ##
129129

130130
# In particular, fully cover all tier 1 targets.
131+
# We also want to run the many-seeds tests on all tier 1 targets.
131132
case $HOST_TARGET in
132133
x86_64-unknown-linux-gnu)
133134
# Host
134135
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
135136
# Extra tier 1
136-
MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
137-
MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests
138-
MIRI_TEST_TARGET=x86_64-apple-darwin run_tests
139-
MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
140-
MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests
137+
# With reduced many-seed count to avoid spending too much time on that.
138+
# (All OSes are run with 64 seeds at least once though via the macOS runner.)
139+
MANY_SEEDS=16 MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
140+
MANY_SEEDS=16 MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests
141+
MANY_SEEDS=16 MIRI_TEST_TARGET=x86_64-apple-darwin run_tests
142+
MANY_SEEDS=16 MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests
141143
# Extra tier 2
142144
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
143145
MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests
@@ -155,13 +157,15 @@ case $HOST_TARGET in
155157
# Host (tier 2)
156158
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
157159
# Extra tier 1
158-
MIRI_TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
160+
MANY_SEEDS=64 MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
161+
MANY_SEEDS=64 MIRI_TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
159162
# Extra tier 2
160163
MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture
161164
;;
162165
i686-pc-windows-msvc)
163166
# Host
164-
# Only smoke-test `many-seeds`; 64 runs take 15min here!
167+
# Only smoke-test `many-seeds`; 64 runs of just the scoped-thread-leak test take 15min here!
168+
# See <https://github.com/rust-lang/miri/issues/3509>.
165169
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=1 TEST_BENCH=1 run_tests
166170
# Extra tier 1
167171
# We really want to ensure a Linux target works on a Windows host,

tests/many-seeds/tls-leak.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
//! Regression test for <https://github.com/rust-lang/rust/issues/123583>.
22
use std::thread;
33

4-
pub(crate) fn with_thread_local() {
4+
fn with_thread_local1() {
55
thread_local! { static X: Box<u8> = Box::new(0); }
66
X.with(|_x| {})
77
}
88

9+
fn with_thread_local2() {
10+
thread_local! { static Y: Box<u8> = Box::new(0); }
11+
Y.with(|_y| {})
12+
}
13+
914
fn main() {
10-
let j2 = thread::spawn(with_thread_local);
11-
with_thread_local();
12-
j2.join().unwrap();
15+
// Here we have two threads racing on initializing the thread-local and adding it to the global
16+
// dtor list (on targets that have such a list, i.e., targets without target_thread_local).
17+
let t = thread::spawn(with_thread_local1);
18+
with_thread_local1();
19+
t.join().unwrap();
20+
21+
// Here we have one thread running the destructors racing with another thread initializing a
22+
// thread-local. The second thread adds a destructor that could be picked up by the first.
23+
let t = thread::spawn(|| { /* immediately just run destructors */ });
24+
with_thread_local2(); // initialize thread-local
25+
t.join().unwrap();
1326
}

0 commit comments

Comments
 (0)