Challenge 6: Safety of NonNull
- Status: Open
- Tracking Issue: #53
- Start date: 2024/08/16
- End date: 2025/04/10
- Reward: N/A
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>::add
NonNull<T>::addr
NonNull<T>::align_offset
NonNull<T>::as_mut<'a>
NonNull<T>::as_mut_ptr
NonNull<T>::as_non_null_ptr
NonNull<T>::as_ptr
NonNull<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_add
NonNull<T>::byte_offset_from<U: ?Sized>
NonNull<T>::byte_offset
NonNull<T>::byte_sub
NonNull<T>::cast<U>
NonNull<T>::copy_from_nonoverlapping
NonNull<T>::copy_from
NonNull<T>::copy_to_nonoverlapping
NonNull<T>::copy_to
NonNull<T>::dangling
NonNull<T>::drop_in_place
NonNull<T>::from_raw_parts
NonNull<T>::get_unchecked_mut<I>
NonNull<T>::is_aligned_to
NonNull<T>::is_aligned
NonNull<T>::is_empty
NonNull<T>::len
NonNull<T>::map_addr
NonNull<T>::new_unchecked
NonNull<T>::new
NonNull<T>::offset_from
NonNull<T>::offset
NonNull<T>::read_unaligned
NonNull<T>::read_volatile
NonNull<T>::read
NonNull<T>::replace
NonNull<T>::slice_from_raw_parts
NonNull<T>::sub_ptr
NonNull<T>::sub
NonNull<T>::swap
NonNull<T>::to_raw_parts
NonNull<T>::with_addr
NonNull<T>::write_bytes
NonNull<T>::write_unaligned
NonNull<T>::write_volatile
NonNull<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.