udoprog / checkers

A sanity checker for global allocations in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Allocator::alloc_zeroed` is unsound

HeroicKatora opened this issue · comments

When the underlying allocator fails, it still constructs a slice with a null pointer as the base of the slice and the length of the requested layout. Note: the basic idea is sound, the slice must have been initialized as required by the unsafe trait GlobalAlloc. One could argue that the check is not very effective at detecting whether the slice is left uninitialized—as the compiler might decide to have it succeed anyways as part of the UB that results from this— but in general it probably work out.