diff options
| author | Ralf Jung <post@ralfj.de> | 2022-08-04 09:01:00 -0400 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-08-18 18:07:39 -0400 |
| commit | 27b044433367d7305f71bcf67dd9b5be0a0bd65a (patch) | |
| tree | 0c6eef8280cb9854fc4cb672c9a42fc1b5293a49 /library/alloc/src | |
| parent | ac66baad1a9787f60ff86fac125da8176e053dbc (diff) | |
| download | rust-27b044433367d7305f71bcf67dd9b5be0a0bd65a.tar.gz rust-27b044433367d7305f71bcf67dd9b5be0a0bd65a.zip | |
add some Miri-only tests
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/sync/tests.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/library/alloc/src/sync/tests.rs b/library/alloc/src/sync/tests.rs index 202d0e7f020..0fae8953aa2 100644 --- a/library/alloc/src/sync/tests.rs +++ b/library/alloc/src/sync/tests.rs @@ -618,3 +618,22 @@ fn test_arc_cyclic_two_refs() { assert_eq!(Arc::strong_count(&two_refs), 3); assert_eq!(Arc::weak_count(&two_refs), 2); } + +/// Test for Arc::drop bug (https://github.com/rust-lang/rust/issues/55005) +#[test] +#[cfg(miri)] // relies on Stacked Borrows in Miri +fn arc_drop_dereferenceable_race() { + // The bug seems to take up to 700 iterations to reproduce with most seeds (tested 0-9). + for _ in 0..750 { + let arc_1 = Arc::new(()); + let arc_2 = arc_1.clone(); + let thread = thread::spawn(|| drop(arc_2)); + // Spin a bit; makes the race more likely to appear + let mut i = 0; + while i < 256 { + i += 1; + } + drop(arc_1); + thread.join().unwrap(); + } +} |
