Skip to content

Commit b8e87d3

Browse files
committed
fix data race in ReentrantLock fallback for targets without 64bit atomics
1 parent 2b1650e commit b8e87d3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/many-seeds/reentrant-lock.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(reentrant_lock)]
2+
//! This is a regression test for
3+
//! <https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/reentrant.20lock.20failure.20on.20musl>.
4+
5+
use std::cell::Cell;
6+
use std::sync::ReentrantLock;
7+
use std::thread;
8+
9+
static LOCK: ReentrantLock<Cell<i32>> = ReentrantLock::new(Cell::new(0));
10+
11+
fn main() {
12+
for _ in 0..20 {
13+
thread::spawn(move || {
14+
let val = LOCK.lock();
15+
val.set(val.get() + 1);
16+
drop(val);
17+
});
18+
}
19+
}

0 commit comments

Comments
 (0)