Skip to content

Conversation

@cbeuw
Copy link
Contributor

@cbeuw cbeuw commented Oct 22, 2025

Add 2+2W litmus tests with the strongest ordering that still allows observing x==y==1

Equivalent cppmem code:

int main() {
  atomic_int x=0; atomic_int y=0;
  {{{ { x.store(1,memory_order_seq_cst); 
        y.store(2,memory_order_seq_cst);
        r1=y.load(memory_order_relaxed);
      }
  ||| { y.store(1,memory_order_release);
        x.store(2,memory_order_seq_cst);
        r2=x.load(memory_order_relaxed);
      }  
  }}}

  return 0;
}

@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

Thank you for contributing to Miri!
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Oct 22, 2025
/// 2+2W variant https://johnwickerson.github.io/papers/memalloy.pdf §4.1
/// 3 SC + 1 Rel is the strongest ordering to still observe x==y==1
fn two_w_two_w() {
check_all_outcomes([1, 1], || {
Copy link
Member

@RalfJung RalfJung Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks y, and it checks that that is always 1...?

The slice here is the set of all outcomes, so [1, 1] is equivalent to [1].

Comment on lines +239 to +244
x.load(Relaxed)
});
let t2 = spawn(move || {
y.store(1, Release);
x.store(2, SeqCst);
y.load(Relaxed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code doesn't match the cppmem code. It should be:

Suggested change
x.load(Relaxed)
});
let t2 = spawn(move || {
y.store(1, Release);
x.store(2, SeqCst);
y.load(Relaxed)
y.load(Relaxed)
});
let t2 = spawn(move || {
y.store(1, Release);
x.store(2, SeqCst);
x.load(Relaxed)

@RalfJung
Copy link
Member

As noted on Zulip, the test is wrong: the y.load and x.load need to be swapped. With the correct version, Miri can't produce the (1, 1) outcome any more.

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Waiting for a review to complete label Oct 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Oct 23, 2025
@cbeuw cbeuw closed this Oct 23, 2025
@rustbot rustbot removed the S-waiting-on-author Status: Waiting for the PR author to address review comments label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants