@@ -343,10 +343,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
343
343
}
344
344
345
345
// Let the machine take some extra action
346
- M :: memory_deallocated ( & mut self . extra , & mut alloc, ptr) ?;
346
+ let size = alloc. size ( ) ;
347
+ M :: memory_deallocated ( & mut self . extra , & mut alloc. extra , ptr, size) ?;
347
348
348
349
// Don't forget to remember size and align of this now-dead allocation
349
- let old = self . dead_alloc_map . insert ( ptr. alloc_id , ( alloc . size ( ) , alloc. align ) ) ;
350
+ let old = self . dead_alloc_map . insert ( ptr. alloc_id , ( size, alloc. align ) ) ;
350
351
if old. is_some ( ) {
351
352
bug ! ( "Nothing can be deallocated twice" ) ;
352
353
}
@@ -591,7 +592,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
591
592
} ,
592
593
) ?;
593
594
if let Some ( ( ptr, alloc) ) = ptr_and_alloc {
594
- M :: memory_read ( & self . extra , alloc, ptr, size) ?;
595
+ M :: memory_read ( & self . extra , & alloc. extra , ptr, size) ?;
595
596
let range = alloc_range ( ptr. offset , size) ;
596
597
Ok ( Some ( AllocRef { alloc, range, tcx : self . tcx , alloc_id : ptr. alloc_id } ) )
597
598
} else {
@@ -660,7 +661,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
660
661
// FIXME: can we somehow avoid looking up the allocation twice here?
661
662
// We cannot call `get_raw_mut` inside `check_and_deref_ptr` as that would duplicate `&mut self`.
662
663
let ( alloc, extra) = self . get_raw_mut ( ptr. alloc_id ) ?;
663
- M :: memory_written ( extra, alloc, ptr, size) ?;
664
+ M :: memory_written ( extra, & mut alloc. extra , ptr, size) ?;
664
665
let range = alloc_range ( ptr. offset , size) ;
665
666
Ok ( Some ( AllocRefMut { alloc, range, tcx, alloc_id : ptr. alloc_id } ) )
666
667
} else {
@@ -1029,7 +1030,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
1029
1030
Some ( src_ptr) => src_ptr,
1030
1031
} ;
1031
1032
let src_alloc = self . get_raw ( src. alloc_id ) ?;
1032
- M :: memory_read ( & self . extra , src_alloc, src, size) ?;
1033
+ M :: memory_read ( & self . extra , & src_alloc. extra , src, size) ?;
1033
1034
// We need the `dest` ptr for the next operation, so we get it now.
1034
1035
// We already did the source checks and called the hooks so we are good to return early.
1035
1036
let dest = match dest {
@@ -1058,7 +1059,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
1058
1059
1059
1060
// Destination alloc preparations and access hooks.
1060
1061
let ( dest_alloc, extra) = self . get_raw_mut ( dest. alloc_id ) ?;
1061
- M :: memory_written ( extra, dest_alloc, dest, size * num_copies) ?;
1062
+ M :: memory_written ( extra, & mut dest_alloc. extra , dest, size * num_copies) ?;
1062
1063
let dest_bytes = dest_alloc
1063
1064
. get_bytes_mut_ptr ( & tcx, alloc_range ( dest. offset , size * num_copies) )
1064
1065
. as_mut_ptr ( ) ;
0 commit comments