@@ -243,11 +243,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
243243
244244 let alloc_kind = self . alloc_kind . remove ( & ptr. alloc_id ) . expect ( "alloc_map out of sync with alloc_kind" ) ;
245245
246- // It is okay for us to still holds locks on deallocation -- for example, we could store data we own
247- // in a local, and the local could be deallocated (from StorageDead) before the function returns.
248- // However, we should check *something*. For now, we make sure that there is no conflicting write
249- // lock by another frame. We *have* to permit deallocation if we hold a read lock.
250- // TODO: Figure out the exact rules here.
246+ // It is okay for us to still holds locks on deallocation -- for example, we could store
247+ // data we own in a local, and the local could be deallocated (from StorageDead) before the
248+ // function returns. However, we should check *something*. For now, we make sure that there
249+ // is no conflicting write lock by another frame. We *have* to permit deallocation if we
250+ // hold a read lock.
251+ // FIXME: Figure out the exact rules here.
251252 M :: free_lock ( self , ptr. alloc_id , alloc. bytes . len ( ) as u64 ) ?;
252253
253254 if alloc_kind != kind {
@@ -521,13 +522,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
521522 size : Size ,
522523 align : Align ,
523524 ) -> EvalResult < ' tcx , & [ u8 ] > {
524- // Zero-sized accesses can use dangling pointers, but they still have to be aligned and non-NULL
525+ // Zero-sized accesses can use dangling pointers,
526+ // but they still have to be aligned and non-NULL
525527 self . check_align ( ptr. into ( ) , align) ?;
526528 if size. bytes ( ) == 0 {
527529 return Ok ( & [ ] ) ;
528530 }
529531 M :: check_locks ( self , ptr, size, AccessKind :: Read ) ?;
530- self . check_bounds ( ptr. offset ( size, self ) ?, true ) ?; // if ptr.offset is in bounds, then so is ptr (because offset checks for overflow)
532+ // if ptr.offset is in bounds, then so is ptr (because offset checks for overflow)
533+ self . check_bounds ( ptr. offset ( size, self ) ?, true ) ?;
531534 let alloc = self . get ( ptr. alloc_id ) ?;
532535 assert_eq ! ( ptr. offset. bytes( ) as usize as u64 , ptr. offset. bytes( ) ) ;
533536 assert_eq ! ( size. bytes( ) as usize as u64 , size. bytes( ) ) ;
@@ -542,13 +545,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
542545 size : Size ,
543546 align : Align ,
544547 ) -> EvalResult < ' tcx , & mut [ u8 ] > {
545- // Zero-sized accesses can use dangling pointers, but they still have to be aligned and non-NULL
548+ // Zero-sized accesses can use dangling pointers,
549+ // but they still have to be aligned and non-NULL
546550 self . check_align ( ptr. into ( ) , align) ?;
547551 if size. bytes ( ) == 0 {
548552 return Ok ( & mut [ ] ) ;
549553 }
550554 M :: check_locks ( self , ptr, size, AccessKind :: Write ) ?;
551- self . check_bounds ( ptr. offset ( size, & * self ) ?, true ) ?; // if ptr.offset is in bounds, then so is ptr (because offset checks for overflow)
555+ // if ptr.offset is in bounds, then so is ptr (because offset checks for overflow)
556+ self . check_bounds ( ptr. offset ( size, & * self ) ?, true ) ?;
552557 let alloc = self . get_mut ( ptr. alloc_id ) ?;
553558 assert_eq ! ( ptr. offset. bytes( ) as usize as u64 , ptr. offset. bytes( ) ) ;
554559 assert_eq ! ( size. bytes( ) as usize as u64 , size. bytes( ) ) ;
@@ -774,14 +779,16 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
774779
775780 /// Read a *non-ZST* scalar
776781 pub fn read_scalar ( & self , ptr : Pointer , ptr_align : Align , size : Size ) -> EvalResult < ' tcx , ScalarMaybeUndef > {
777- self . check_relocation_edges ( ptr, size) ?; // Make sure we don't read part of a pointer as a pointer
782+ // Make sure we don't read part of a pointer as a pointer
783+ self . check_relocation_edges ( ptr, size) ?;
778784 let endianness = self . endianness ( ) ;
779785 // get_bytes_unchecked tests alignment
780786 let bytes = self . get_bytes_unchecked ( ptr, size, ptr_align. min ( self . int_align ( size) ) ) ?;
781787 // Undef check happens *after* we established that the alignment is correct.
782788 // We must not return Ok() for unaligned pointers!
783789 if self . check_defined ( ptr, size) . is_err ( ) {
784- // this inflates undefined bytes to the entire scalar, even if only a few bytes are undefined
790+ // this inflates undefined bytes to the entire scalar,
791+ // even if only a few bytes are undefined
785792 return Ok ( ScalarMaybeUndef :: Undef ) ;
786793 }
787794 // Now we do the actual reading
0 commit comments