@@ -208,7 +208,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
208
208
let new_ptr = self . allocate ( new_mem_pos, kind) ;
209
209
let old_size = match old_mem_pos {
210
210
Some ( old_mem_pos) => old_mem_pos. size ,
211
- None => self . get_raw ( ptr. alloc_id ) ?. size ,
211
+ None => self . get_raw ( ptr. alloc_id ) ?. mem_pos . size ,
212
212
} ;
213
213
self . copy (
214
214
ptr,
@@ -268,21 +268,23 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
268
268
format!( "{:?}" , kind) ,
269
269
) )
270
270
}
271
+
272
+ let bytes_mem_pos = alloc. mem_pos ;
273
+
271
274
if let Some ( mem_pos) = old_mem_pos {
272
- if mem_pos != MemoryPosition :: new ( alloc. size , alloc. align ) {
273
- let got_mem_pos = MemoryPosition :: new ( alloc. size , alloc. align ) ;
274
- throw_unsup ! ( IncorrectAllocationInformation ( mem_pos, got_mem_pos) )
275
+ if mem_pos != bytes_mem_pos {
276
+ throw_unsup ! ( IncorrectAllocationInformation ( mem_pos, bytes_mem_pos) )
275
277
}
276
278
}
277
279
278
280
// Let the machine take some extra action
279
- let size = alloc. size ;
281
+ let size = alloc. mem_pos . size ;
280
282
AllocationExtra :: memory_deallocated ( & mut alloc, ptr, size) ?;
281
283
282
284
// Don't forget to remember size and align of this now-dead allocation
283
285
let old = self . dead_alloc_map . insert (
284
286
ptr. alloc_id ,
285
- ( alloc. size , alloc. align )
287
+ ( alloc. mem_pos . size , alloc. mem_pos . align )
286
288
) ;
287
289
if old. is_some ( ) {
288
290
bug ! ( "Nothing can be deallocated twice" ) ;
@@ -561,7 +563,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
561
563
// a) cause cycles in case `id` refers to a static
562
564
// b) duplicate a static's allocation in miri
563
565
if let Some ( ( _, alloc) ) = self . alloc_map . get ( id) {
564
- return Ok ( ( alloc. size , alloc. align ) ) ;
566
+ return Ok ( ( alloc. mem_pos . size , alloc. mem_pos . align ) ) ;
565
567
}
566
568
567
569
// # Function pointers
@@ -589,7 +591,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
589
591
Some ( GlobalAlloc :: Memory ( alloc) ) =>
590
592
// Need to duplicate the logic here, because the global allocations have
591
593
// different associated types than the interpreter-local ones.
592
- Ok ( ( alloc. size , alloc. align ) ) ,
594
+ Ok ( ( alloc. mem_pos . size , alloc. mem_pos . align ) ) ,
593
595
Some ( GlobalAlloc :: Function ( _) ) =>
594
596
bug ! ( "We already checked function pointers above" ) ,
595
597
// The rest must be dead.
@@ -651,7 +653,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
651
653
let prefix_len = msg. len ( ) ;
652
654
let mut relocations = vec ! [ ] ;
653
655
654
- for i in 0 ..alloc. size . bytes ( ) {
656
+ for i in 0 ..alloc. mem_pos . size . bytes ( ) {
655
657
let i = Size :: from_bytes ( i) ;
656
658
if let Some ( & ( _, target_id) ) = alloc. relocations ( ) . get ( & i) {
657
659
if allocs_seen. insert ( target_id) {
@@ -675,8 +677,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
675
677
trace ! (
676
678
"{}({} bytes, alignment {}){}" ,
677
679
msg,
678
- alloc. size. bytes( ) ,
679
- alloc. align. bytes( ) ,
680
+ alloc. mem_pos . size. bytes( ) ,
681
+ alloc. mem_pos . align. bytes( ) ,
680
682
extra
681
683
) ;
682
684
0 commit comments