Misaligned pointer exposure in `visit` of `PodVecView`
shinmao opened this issue · comments
Rafael commented
The source of unsoundness
Hi, we found some unsound implementation might expose the misaligned pointer and led to undefined behavior:
Fyrox/fyrox-core/src/visitor.rs
Lines 194 to 208 in 0695c61
First of all, the unsound callee would be safe function
visit
. At line 207, it would cast mutable u8
pointer to the pointer of generic type in PodVecView
. This safe function was declared as private; therefore, it depends on internal usage of the library. At the end, we found that,Fyrox/src/scene/terrain/mod.rs
Lines 185 to 188 in 0695c61
At line 187, we knew that
PodVecView.vec
was init as Vec<f32>
now. When view.visit()
was called, the u8
pointer would be casted to f32
pointer which had a stronger alignment requirement. Please check and happy to have discussion.Dmitry Stepanov commented
Should be fixed now.