3 ms·
> Issue it had was safe code was invalidating the invariants unsafe code was relying on. Iirc alignment. You do recall correctly. The safe code was producing a
by bigstrat2003 3y ago
> Issue it had was safe code was invalidating the invariants unsafe code was relying on. Iirc alignment.
You do recall correctly. The safe code was producing a pointer with alignment that was off, and the unsafe code dereferenced it without checking. I felt that it was kind of a bad take when several people said that it was UB caused by safe code, because really the issue was that the unsafe code wasn't doing its job. The Rust unsafe model is that you can't trust safe code when inside unsafe code. It's on the unsafe code to uphold invariants which it requires, not the safe code which calls it