Skip to content

Fix uninit_vector UB by returning Vec<MaybeUninit<T>>#410

Open
MavenRain wants to merge 1 commit intofacebook:mainfrom
MavenRain:fix/uninit-vector-soundness
Open

Fix uninit_vector UB by returning Vec<MaybeUninit<T>>#410
MavenRain wants to merge 1 commit intofacebook:mainfrom
MavenRain:fix/uninit-vector-soundness

Conversation

@MavenRain
Copy link
Copy Markdown

uninit_vector previously returned Vec with uninitialized memory, which is undefined behavior (especially for types implementing Drop). Change return type to Vec<MaybeUninit> and add assume_init_vec helper for zero-cost conversion after initialization. Update all ~30 call sites across math, crypto, fri, prover, and examples crates.

Closes #396

  uninit_vector previously returned Vec<T> with uninitialized memory,
  which is undefined behavior (especially for types implementing Drop).
  Change return type to Vec<MaybeUninit<T>> and add assume_init_vec
  helper for zero-cost conversion after initialization. Update all
  ~30 call sites across math, crypto, fri, prover, and examples crates.

  Closes facebook#396
@meta-cla meta-cla bot added the cla signed label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uninit_vector should return Vec<MaybeUninit<T>>

1 participant