File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/tools/miri/tests/pass/concurrency Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,22 @@ fn mixed_size_read_read() {
166166 } ) ;
167167}
168168
169+ fn failing_rmw_is_read ( ) {
170+ let a = AtomicUsize :: new ( 0 ) ;
171+ thread:: scope ( |s| {
172+ s. spawn ( || unsafe {
173+ // Non-atomic read.
174+ let _val = * ( & a as * const AtomicUsize ) . cast :: < usize > ( ) ;
175+ } ) ;
176+
177+ s. spawn ( || {
178+ // RMW that will fail.
179+ // This is not considered a write, so there is no data race here.
180+ a. compare_exchange ( 1 , 2 , Ordering :: SeqCst , Ordering :: SeqCst ) . unwrap_err ( ) ;
181+ } ) ;
182+ } ) ;
183+ }
184+
169185pub fn main ( ) {
170186 test_fence_sync ( ) ;
171187 test_multiple_reads ( ) ;
@@ -174,4 +190,5 @@ pub fn main() {
174190 test_read_read_race1 ( ) ;
175191 test_read_read_race2 ( ) ;
176192 mixed_size_read_read ( ) ;
193+ failing_rmw_is_read ( ) ;
177194}
You can’t perform that action at this time.
0 commit comments