@@ -874,8 +874,8 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
874874 // We need a frozen-sensitive reborrow.
875875 // We have to use shared references to alloc/memory_extra here since
876876 // `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
879879 . stacked_borrows
880880 . as_ref ( )
881881 . expect ( "we should have Stacked Borrows data" )
@@ -910,7 +910,16 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
910910 ) ;
911911 stacked_borrows. for_each ( range, dcx, |stack, dcx, exposed_tags| {
912912 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 ( ( ) )
914923 } ) ?;
915924 return Ok ( Some ( alloc_id) ) ;
916925 }
@@ -938,6 +947,14 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
938947 stacked_borrows. for_each ( range, dcx, |stack, dcx, exposed_tags| {
939948 stack. grant ( orig_tag, item, access, & global, dcx, exposed_tags)
940949 } ) ?;
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+ }
941958
942959 Ok ( Some ( alloc_id) )
943960 }
0 commit comments