@@ -847,13 +847,27 @@ impl VClockAlloc {
847
847
let mut action = Cow :: Borrowed ( action) ;
848
848
let mut involves_non_atomic = true ;
849
849
let write_clock;
850
- #[ rustfmt:: skip]
851
850
let ( other_action, other_thread, other_clock) =
852
- if mem_clocks. write . 1 > current_clocks. clock [ mem_clocks. write . 0 ] {
851
+ // First check the atomic-nonatomic cases. If it looks like multiple
852
+ // cases apply, this one should take precedence, else it might look like
853
+ // we are reporting races between two non-atomic reads.
854
+ if !is_atomic &&
855
+ let Some ( atomic) = mem_clocks. atomic ( ) &&
856
+ let Some ( idx) = Self :: find_gt_index ( & atomic. write_vector , & current_clocks. clock )
857
+ {
858
+ ( format ! ( "Atomic Store" ) , idx, & atomic. write_vector )
859
+ } else if !is_atomic &&
860
+ let Some ( atomic) = mem_clocks. atomic ( ) &&
861
+ let Some ( idx) = Self :: find_gt_index ( & atomic. read_vector , & current_clocks. clock )
862
+ {
863
+ ( format ! ( "Atomic Load" ) , idx, & atomic. read_vector )
864
+ // Then check races with non-atomic writes/reads.
865
+ } else if mem_clocks. write . 1 > current_clocks. clock [ mem_clocks. write . 0 ] {
853
866
write_clock = mem_clocks. write ( ) ;
854
867
( mem_clocks. write_type . get_descriptor ( ) . to_owned ( ) , mem_clocks. write . 0 , & write_clock)
855
868
} else if let Some ( idx) = Self :: find_gt_index ( & mem_clocks. read , & current_clocks. clock ) {
856
869
( format ! ( "Read" ) , idx, & mem_clocks. read )
870
+ // Finally, mixed-size races.
857
871
} else if is_atomic && let Some ( atomic) = mem_clocks. atomic ( ) && atomic. size != access_size {
858
872
// This is only a race if we are not synchronized with all atomic accesses, so find
859
873
// the one we are not synchronized with.
@@ -871,27 +885,8 @@ impl VClockAlloc {
871
885
"Failed to report data-race for mixed-size access: no race found"
872
886
)
873
887
}
874
- } else if !is_atomic {
875
- if let Some ( atomic) = mem_clocks. atomic ( ) {
876
- if let Some ( idx) = Self :: find_gt_index ( & atomic. write_vector , & current_clocks. clock )
877
- {
878
- ( format ! ( "Atomic Store" ) , idx, & atomic. write_vector )
879
- } else if let Some ( idx) =
880
- Self :: find_gt_index ( & atomic. read_vector , & current_clocks. clock )
881
- {
882
- ( format ! ( "Atomic Load" ) , idx, & atomic. read_vector )
883
- } else {
884
- unreachable ! (
885
- "Failed to report data-race for non-atomic operation: no race found"
886
- )
887
- }
888
- } else {
889
- unreachable ! (
890
- "Failed to report data-race for non-atomic operation: no atomic component"
891
- )
892
- }
893
888
} else {
894
- unreachable ! ( "Failed to report data-race for atomic operation " )
889
+ unreachable ! ( "Failed to report data-race" )
895
890
} ;
896
891
897
892
// Load elaborated thread information about the racing thread actions.
0 commit comments