@@ -847,13 +847,27 @@ impl VClockAlloc {
847847 let mut action = Cow :: Borrowed ( action) ;
848848 let mut involves_non_atomic = true ;
849849 let write_clock;
850- #[ rustfmt:: skip]
851850 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 ] {
853866 write_clock = mem_clocks. write ( ) ;
854867 ( mem_clocks. write_type . get_descriptor ( ) . to_owned ( ) , mem_clocks. write . 0 , & write_clock)
855868 } else if let Some ( idx) = Self :: find_gt_index ( & mem_clocks. read , & current_clocks. clock ) {
856869 ( format ! ( "Read" ) , idx, & mem_clocks. read )
870+ // Finally, mixed-size races.
857871 } else if is_atomic && let Some ( atomic) = mem_clocks. atomic ( ) && atomic. size != access_size {
858872 // This is only a race if we are not synchronized with all atomic accesses, so find
859873 // the one we are not synchronized with.
@@ -871,27 +885,8 @@ impl VClockAlloc {
871885 "Failed to report data-race for mixed-size access: no race found"
872886 )
873887 }
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- }
893888 } else {
894- unreachable ! ( "Failed to report data-race for atomic operation " )
889+ unreachable ! ( "Failed to report data-race" )
895890 } ;
896891
897892 // Load elaborated thread information about the racing thread actions.
0 commit comments