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() {
166
166
} ) ;
167
167
}
168
168
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
+
169
185
pub fn main ( ) {
170
186
test_fence_sync ( ) ;
171
187
test_multiple_reads ( ) ;
@@ -174,4 +190,5 @@ pub fn main() {
174
190
test_read_read_race1 ( ) ;
175
191
test_read_read_race2 ( ) ;
176
192
mixed_size_read_read ( ) ;
193
+ failing_rmw_is_read ( ) ;
177
194
}
You can’t perform that action at this time.
0 commit comments