@@ -50,7 +50,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
50
50
. memory
51
51
. allocate ( Size :: from_bytes ( size) , align, kind. into ( ) ) ;
52
52
if zero_init {
53
- // We just allocated this, the access cannot fail
53
+ // We just allocated this, the access is definitely in-bounds.
54
54
this. memory
55
55
. get_mut ( ptr. alloc_id )
56
56
. unwrap ( )
@@ -227,7 +227,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
227
227
Align :: from_bytes ( align) . unwrap ( ) ,
228
228
MiriMemoryKind :: Rust . into ( ) ,
229
229
) ;
230
- // We just allocated this, the access cannot fail
230
+ // We just allocated this, the access is definitely in-bounds.
231
231
this. memory
232
232
. get_mut ( ptr. alloc_id )
233
233
. unwrap ( )
@@ -643,7 +643,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
643
643
644
644
// Hook pthread calls that go to the thread-local storage memory subsystem.
645
645
"pthread_key_create" => {
646
- let key_ptr = this. read_scalar ( args[ 0 ] ) ? . not_undef ( ) ?;
646
+ let key_place = this. deref_operand ( args[ 0 ] ) ?;
647
647
648
648
// Extract the function type out of the signature (that seems easier than constructing it ourselves).
649
649
let dtor = match this. test_null ( this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?) ? {
@@ -668,16 +668,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
668
668
throw_unsup ! ( OutOfTls ) ;
669
669
}
670
670
671
- let key_ptr = this
672
- . memory
673
- . check_ptr_access ( key_ptr, key_layout. size , key_layout. align . abi ) ?
674
- . expect ( "cannot be a ZST" ) ;
675
- this. memory . get_mut ( key_ptr. alloc_id ) ?. write_scalar (
676
- tcx,
677
- key_ptr,
678
- Scalar :: from_uint ( key, key_layout. size ) . into ( ) ,
679
- key_layout. size ,
680
- ) ?;
671
+ this. write_scalar ( Scalar :: from_uint ( key, key_layout. size ) , key_place. into ( ) ) ?;
681
672
682
673
// Return success (`0`).
683
674
this. write_null ( dest) ?;
@@ -856,6 +847,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
856
847
let system_info_ptr = this
857
848
. check_mplace_access ( system_info, None ) ?
858
849
. expect ( "cannot be a ZST" ) ;
850
+ // We rely on `deref_operand` doing bounds checks for us.
859
851
// Initialize with `0`.
860
852
this. memory
861
853
. get_mut ( system_info_ptr. alloc_id ) ?
@@ -992,6 +984,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
992
984
fn set_last_error ( & mut self , scalar : Scalar < Tag > ) -> InterpResult < ' tcx > {
993
985
let this = self . eval_context_mut ( ) ;
994
986
let errno_ptr = this. machine . last_error . unwrap ( ) ;
987
+ // We allocated this during machine initialziation so the bounds are fine.
995
988
this. memory . get_mut ( errno_ptr. alloc_id ) ?. write_scalar (
996
989
& * this. tcx ,
997
990
errno_ptr,
0 commit comments