@@ -533,9 +533,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
533
533
) -> InterpResult < ' tcx > {
534
534
let this = self . eval_context_mut ( ) ;
535
535
let protector = if protect { Some ( this. frame ( ) . extra ) } else { None } ;
536
- let ptr = this. memory . check_ptr_access ( place. ptr , size, place. align )
537
- . expect ( "validity checks should have excluded dangling/unaligned pointer" )
538
- . expect ( "we shouldn't get here for ZST" ) ;
536
+ let ptr = place. ptr . to_ptr ( ) . expect ( "we should have a proper pointer" ) ;
539
537
trace ! ( "reborrow: {} reference {:?} derived from {:?} (pointee {}): {:?}, size {}" ,
540
538
kind, new_tag, ptr. tag, place. layout. ty, ptr. erase_tag( ) , size. bytes( ) ) ;
541
539
@@ -583,11 +581,13 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
583
581
let size = this. size_and_align_of_mplace ( place) ?
584
582
. map ( |( size, _) | size)
585
583
. unwrap_or_else ( || place. layout . size ) ;
584
+ // We can see dangling ptrs in here e.g. after a Box's `Unique` was
585
+ // updated using "self.0 = ..." (can happen in Box::from_raw); see miri#1050.
586
+ let place = this. mplace_access_checked ( place) ?;
586
587
if size == Size :: ZERO {
587
588
// Nothing to do for ZSTs.
588
589
return Ok ( * val) ;
589
590
}
590
- let place = this. force_mplace_ptr ( place) ?;
591
591
592
592
// Compute new borrow.
593
593
let new_tag = match kind {
0 commit comments