Challenge 6: Safety of NonNull
- Status: Resolved
- Tracking Issue: #53
- Start date: 2024/08/16
- End date: 2025/04/10
- Reward: N/A
- Contributors: Quinyuan Wu, Daniel Tu, Dhvani Kapadia and Jiun Chi Yang
Goal
Verify absence of undefined behavior of the ptr::NonNull module.
Most of its functions are marked unsafe, yet they are used in 62 other modules
of the standard library.
Success Criteria
Prove absence of undefined behavior of the following 48 public functions. You may wish to do so by attaching pre- and postconditions to these, and then (if needed by the tooling that you choose to use) adding verification harnesses.
NonNull<T>::addNonNull<T>::addrNonNull<T>::align_offsetNonNull<T>::as_mut<'a>NonNull<T>::as_mut_ptrNonNull<T>::as_non_null_ptrNonNull<T>::as_ptrNonNull<T>::as_ref<'a>NonNull<T>::as_uninit_mut<'a>NonNull<T>::as_uninit_ref<'a>NonNull<T>::as_uninit_slice<'a>NonNull<T>::as_uninit_slice_mut<'a>NonNull<T>::byte_addNonNull<T>::byte_offset_from<U: ?Sized>NonNull<T>::byte_offsetNonNull<T>::byte_subNonNull<T>::cast<U>NonNull<T>::copy_from_nonoverlappingNonNull<T>::copy_fromNonNull<T>::copy_to_nonoverlappingNonNull<T>::copy_toNonNull<T>::danglingNonNull<T>::drop_in_placeNonNull<T>::from_raw_partsNonNull<T>::get_unchecked_mut<I>NonNull<T>::is_aligned_toNonNull<T>::is_alignedNonNull<T>::is_emptyNonNull<T>::lenNonNull<T>::map_addrNonNull<T>::new_uncheckedNonNull<T>::newNonNull<T>::offset_fromNonNull<T>::offsetNonNull<T>::read_unalignedNonNull<T>::read_volatileNonNull<T>::readNonNull<T>::replaceNonNull<T>::slice_from_raw_partsNonNull<T>::sub_ptrNonNull<T>::subNonNull<T>::swapNonNull<T>::to_raw_partsNonNull<T>::with_addrNonNull<T>::write_bytesNonNull<T>::write_unalignedNonNull<T>::write_volatileNonNull<T>::write
List of UBs
In addition to any properties called out as SAFETY comments in the source
code,
all proofs must automatically ensure the absence of the following undefined behaviors:
- Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer.
- Reading from uninitialized memory.
- Mutating immutable bytes.
- Producing an invalid value
Note: All solutions to verification challenges need to satisfy the criteria established in the challenge book in addition to the ones listed above.