Skip to content

Commit 5c7f08d

Browse files
committed
Add a loom model that checks for a race between leak and drop
1 parent 1f82229 commit 5c7f08d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: src/arc_str.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1678,4 +1678,20 @@ mod loomtest {
16781678
t2.join().unwrap();
16791679
});
16801680
}
1681+
1682+
#[test]
1683+
fn leak_drop() {
1684+
loom::model(|| {
1685+
let a1 = ArcStr::from("foo");
1686+
let a2 = a1.clone();
1687+
1688+
let t1 = thread::spawn(move || {
1689+
drop(a1);
1690+
});
1691+
let t2 = thread::spawn(move || a2.leak());
1692+
t1.join().unwrap();
1693+
let leaked: &'static str = t2.join().unwrap();
1694+
assert_eq!(leaked, "foo");
1695+
});
1696+
}
16811697
}

0 commit comments

Comments
 (0)