-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use T aligned pointer in TempFdArray #241
base: master
Are you sure you want to change the base?
Conversation
55fa419
to
8ddf5ed
Compare
8ddf5ed
to
ebb1ce1
Compare
Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
ebb1ce1
to
5f624c2
Compare
Formatting and clippy should be fine now :) |
let len = BUFFER_LENGTH * self.flush_n; | ||
// Expect T to be non-ZST | ||
let layout = std::alloc::Layout::array::<ManuallyDrop<T>>(len).unwrap(); | ||
let ptr = std::alloc::alloc(layout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If preferable Vec<MaybeUninit<ManuallyDrop<T>>>
could be used here to initialize file_buffer
instead of direct alloc
call.
@YangKeao hello, do you have any estimates on reviewing this PR? |
We also experience issue #232 on rust I've tried applying the modifications in this PR, and it appears to fully resolve the startup error in our project. (letting us now use Is there a blocker on merging of this PR? Or other ways we can help get it validated/merged? |
hi @Erigara , I am wondering whether there is specific condition that could trigger this panic on unaligned pointer with AFAIK, in any usages of However, not all usage of |
Fix for problem highlighted by #232.
I've observed app crash on my MacOS m1 machine with
frame-pointer
feature enabled due to unaligned pointer inslice_from_raw_parts
.Direct call to
alloc
is used to create properly aligned pointer.ManuallyDrop<T>
was used instead ofT
when creatingTempFdArrayIterator
to prevent use after drop sincetry_iter
might be called more than once (not sure that strictly required since afaikUnresolvedFrames
shouldn't allocate any memory).