Skip to content

Commit d4b592e

Browse files
committed
Fail 80% of the time on weak cmpxchg, not 50%
1 parent efd2d55 commit d4b592e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/data_race.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
567567
let old = this.allow_data_races_mut(|this| this.read_immediate(place.into()))?;
568568
// `binary_op` will bail if either of them is not a scalar.
569569
let eq = this.overflowing_binary_op(mir::BinOp::Eq, old, expect_old)?.0;
570-
// If the operation would succeed, but is "weak", fail 50% of the time.
570+
// If the operation would succeed, but is "weak", fail 80% of the time.
571571
// FIXME: this is quite arbitrary.
572572
let cmpxchg_success = eq.to_bool()?
573-
&& (!can_fail_spuriously || this.memory.extra.rng.borrow_mut().gen_range(0, 2) == 0);
573+
&& (!can_fail_spuriously || this.memory.extra.rng.borrow_mut().gen_range(0, 10) < 8);
574574
let res = Immediate::ScalarPair(
575575
old.to_scalar_or_uninit(),
576576
Scalar::from_bool(cmpxchg_success).into(),

tests/run-pass/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn atomic_fences() {
8989

9090
fn weak_sometimes_fails() {
9191
let atomic = AtomicBool::new(false);
92-
let tries = 20;
92+
let tries = 100;
9393
for _ in 0..tries {
9494
let cur = atomic.load(Relaxed);
9595
// Try (weakly) to flip the flag.

0 commit comments

Comments
 (0)