UB in build script
nissaofthesea opened this issue · 2 comments
the build script creates uninitialized integers in a few places:
Line 13 in 47c2999
Lines 43 to 49 in 47c2999
Line 135 in 47c2999
afaik, this is undefined behavior (excerpt from MaybeUninit type docs)
Moreover, uninitialized memory is special in that it does not have a fixed value (“fixed” meaning “it won’t change without being written to”). Reading the same uninitialized byte multiple times can give different results. This makes it undefined behavior to have uninitialized data in a variable even if that variable has an integer type, which otherwise can hold any fixed bit pattern:
use std::mem::{self, MaybeUninit}; let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! ⚠️ // The equivalent code with `MaybeUninit<i32>`: let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
i haven't looked at the code in too much detail but this may be an issue if there's references to this data before it's been initialized for reals.