AlignedBoxedSlice<T> is unsound in multiple places:
The safety invariants of Layout::from_size_align_unchecked are not always fulfilled: The size parameter can overflow isize for some lengths
NonNull::new_unchecked(alloc(...)): alloc can return a null pointer on allocation failure
The initialization code in AlignedBoxedSlice::new creates a mutable slice from uninitialized memory (instead of ptr::write or MaybeUninit)
Pretty much the same problems also existed in v_frame. Those were fixed, more issues were found and the implementation was ultimately replaced and aligned-vec was used instead. I think it could be used in rav1e too. Maybe Aligned<T> and the entirety of align.rs could be removed then because it also has an unsound function.
AlignedBoxedSlice<T>
is unsound in multiple places:Layout::from_size_align_unchecked
are not always fulfilled: Thesize
parameter can overflowisize
for some lengthsNonNull::new_unchecked(alloc(...))
:alloc
can return a null pointer on allocation failureAlignedBoxedSlice::new
creates a mutable slice from uninitialized memory (instead of ptr::write orMaybeUninit
)Pretty much the same problems also existed in v_frame. Those were fixed, more issues were found and the implementation was ultimately replaced and
aligned-vec
was used instead. I think it could be used in rav1e too. MaybeAligned<T>
and the entirety ofalign.rs
could be removed then because it also has an unsound function.