You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zeroize 1.9.0: the optimization_barrier non-asm fallback reads possibly uninitialized memory as u8 (UB from safe code) #1549
On targets without stable asm! (for example wasm32-unknown-unknown), and under
Miri, optimization_barrier<T: ?Sized>(val: &T) (src/barrier.rs:92-100) calls custom_black_box(ptr.cast::<u8>()), which does core::ptr::read_volatile(p) with p: *const u8. If byte 0 of *val is uninitialized, producing that u8 is
Undefined Behaviour. Byte 0 is uninitialized for padding, for MaybeUninit, or for the
payload bytes of a niche-encoded enum after a typed write.
optimization_barrier is a safe pub fn, so safe code can trigger this, e.g. zeroize::optimization_barrier(&core::mem::MaybeUninit::<u8>::uninit()).
We see that #1535 removed the internal callers, but barrier.rs on master is unchanged.
Suggested fix: read_volatile(p.cast::<core::mem::MaybeUninit<u8>>()), or drop custom_black_box and rely on core::hint::black_box alone.
Activity
docs(supply-chain): record #322 merges, filed upstream issues, dalek …
newpavlov commentedon Oct 6, 2026
@tarcieri
Could you cut v1.9.1 after #1551 is merged?
tarcieri commentedon Oct 6, 2026
Hmm, I now see we don't have Miri set up to run in CI. Let me fix that really quick.