@@ -499,7 +499,7 @@ impl MemoryCellClocks {
499
499
Ok ( ( ) )
500
500
}
501
501
502
- /// Detect data-races with an atomic read, caused by a non-atomic access that does
502
+ /// Detect data-races with an atomic read, caused by a non-atomic write that does
503
503
/// not happen-before the atomic-read.
504
504
fn atomic_read_detect (
505
505
& mut self ,
@@ -510,12 +510,8 @@ impl MemoryCellClocks {
510
510
trace ! ( "Atomic read with vectors: {:#?} :: {:#?}" , self , thread_clocks) ;
511
511
let atomic = self . atomic_access ( thread_clocks, access_size) ?;
512
512
atomic. read_vector . set_at_index ( & thread_clocks. clock , index) ;
513
- // Make sure the last non-atomic write and all non-atomic reads were before this access.
514
- if self . write_was_before ( & thread_clocks. clock ) && self . read <= thread_clocks. clock {
515
- Ok ( ( ) )
516
- } else {
517
- Err ( DataRace )
518
- }
513
+ // Make sure the last non-atomic write was before this access.
514
+ if self . write_was_before ( & thread_clocks. clock ) { Ok ( ( ) ) } else { Err ( DataRace ) }
519
515
}
520
516
521
517
/// Detect data-races with an atomic write, either with a non-atomic read or with
@@ -552,11 +548,9 @@ impl MemoryCellClocks {
552
548
}
553
549
thread_clocks. clock . index_mut ( index) . set_read_type ( read_type) ;
554
550
if self . write_was_before ( & thread_clocks. clock ) {
551
+ // We must be ordered-after all atomic writes.
555
552
let race_free = if let Some ( atomic) = self . atomic ( ) {
556
- // We must be ordered-after all atomic accesses, reads and writes.
557
- // This ensures we don't mix atomic and non-atomic accesses.
558
553
atomic. write_vector <= thread_clocks. clock
559
- && atomic. read_vector <= thread_clocks. clock
560
554
} else {
561
555
true
562
556
} ;
@@ -957,9 +951,7 @@ impl VClockAlloc {
957
951
let mut other_size = None ; // if `Some`, this was a size-mismatch race
958
952
let write_clock;
959
953
let ( other_access, other_thread, other_clock) =
960
- // First check the atomic-nonatomic cases. If it looks like multiple
961
- // cases apply, this one should take precedence, else it might look like
962
- // we are reporting races between two non-atomic reads.
954
+ // First check the atomic-nonatomic cases.
963
955
if !access. is_atomic ( ) &&
964
956
let Some ( atomic) = mem_clocks. atomic ( ) &&
965
957
let Some ( idx) = Self :: find_gt_index ( & atomic. write_vector , & active_clocks. clock )
@@ -1007,10 +999,7 @@ impl VClockAlloc {
1007
999
assert ! ( !involves_non_atomic) ;
1008
1000
Some ( "overlapping unsynchronized atomic accesses must use the same access size" )
1009
1001
} else if access. is_read ( ) && other_access. is_read ( ) {
1010
- assert ! ( involves_non_atomic) ;
1011
- Some (
1012
- "overlapping atomic and non-atomic accesses must be synchronized, even if both are read-only" ,
1013
- )
1002
+ panic ! ( "there should be no same-size read-read races" )
1014
1003
} else {
1015
1004
None
1016
1005
} ;
0 commit comments