@@ -533,9 +533,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
533533 ) -> InterpResult < ' tcx > {
534534 let this = self . eval_context_mut ( ) ;
535535 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" ) ;
539537 trace ! ( "reborrow: {} reference {:?} derived from {:?} (pointee {}): {:?}, size {}" ,
540538 kind, new_tag, ptr. tag, place. layout. ty, ptr. erase_tag( ) , size. bytes( ) ) ;
541539
@@ -583,11 +581,13 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
583581 let size = this. size_and_align_of_mplace ( place) ?
584582 . map ( |( size, _) | size)
585583 . 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) ?;
586587 if size == Size :: ZERO {
587588 // Nothing to do for ZSTs.
588589 return Ok ( * val) ;
589590 }
590- let place = this. force_mplace_ptr ( place) ?;
591591
592592 // Compute new borrow.
593593 let new_tag = match kind {
0 commit comments