@@ -874,8 +874,8 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
874
874
// We need a frozen-sensitive reborrow.
875
875
// We have to use shared references to alloc/memory_extra here since
876
876
// `visit_freeze_sensitive` needs to access the global state.
877
- let extra = this. get_alloc_extra ( alloc_id) ?;
878
- let mut stacked_borrows = extra
877
+ let alloc_extra = this. get_alloc_extra ( alloc_id) ?;
878
+ let mut stacked_borrows = alloc_extra
879
879
. stacked_borrows
880
880
. as_ref ( )
881
881
. expect ( "we should have Stacked Borrows data" )
@@ -910,7 +910,16 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
910
910
) ;
911
911
stacked_borrows. for_each ( range, dcx, |stack, dcx, exposed_tags| {
912
912
stack. grant ( orig_tag, item, access, & global, dcx, exposed_tags)
913
- } )
913
+ } ) ?;
914
+ drop ( global) ;
915
+ if let Some ( access) = access {
916
+ assert ! ( access == AccessKind :: Read ) ;
917
+ // Make sure the data race model also knows about this.
918
+ if let Some ( data_race) = alloc_extra. data_race . as_ref ( ) {
919
+ data_race. read ( alloc_id, range, & this. machine ) ?;
920
+ }
921
+ }
922
+ Ok ( ( ) )
914
923
} ) ?;
915
924
return Ok ( Some ( alloc_id) ) ;
916
925
}
@@ -938,6 +947,14 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
938
947
stacked_borrows. for_each ( range, dcx, |stack, dcx, exposed_tags| {
939
948
stack. grant ( orig_tag, item, access, & global, dcx, exposed_tags)
940
949
} ) ?;
950
+ drop ( global) ;
951
+ if let Some ( access) = access {
952
+ assert ! ( access == AccessKind :: Write ) ;
953
+ // Make sure the data race model also knows about this.
954
+ if let Some ( data_race) = alloc_extra. data_race . as_mut ( ) {
955
+ data_race. write ( alloc_id, range, machine) ?;
956
+ }
957
+ }
941
958
942
959
Ok ( Some ( alloc_id) )
943
960
}
0 commit comments