forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 254
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
Use MaybeUninit more properly in streamer::batch_send() #3325
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Two things as I review this real quick:
|
steviez
force-pushed
the
streamer_send_ub
branch
from
October 28, 2024 06:18
e8047f5
to
87cd227
Compare
steviez
changed the title
Avoid assume_init() on uninitialized struct in streamer::batch_send()
Use MaybeUninit more properly in streamer::batch_send()
Oct 28, 2024
steviez
force-pushed
the
streamer_send_ub
branch
from
October 28, 2024 06:57
87cd227
to
fbd2391
Compare
alessandrod
previously approved these changes
Oct 28, 2024
alessandrod
approved these changes
Oct 28, 2024
behzadnouri
approved these changes
Oct 29, 2024
ray-kast
pushed a commit
to abklabs/agave
that referenced
this pull request
Nov 27, 2024
An array of iovec was previously created as a MaybeUninit, and then immediately marked as initialized with assume_init(). This was likely a workaround was iovec not having a Default implementation, but this also created undefined behavior since the iovec type has pointers. With the bump to rust 1.82, this was causing the validator to crash This change uses the MaybeUninit interface to more properly create the libc types as MaybeUninit, initialize them, and then transmute them to their regular, initialized counterpart types
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
batch_send()
has undefined behavior. Some uninitialized data is marked as initialized withassume_init()
even though it hasn't actually been initialized:agave/streamer/src/sendmmsg.rs
Lines 138 to 140 in 10bebfa
This is problematic since the iovec struct has a pointer:
With rust 1.82, this made the validator start crashing:
Summary of Changes
MaybeUninit
interface to initializeiovec
'sMaybeUninit
interface to initializemmsghdr
'smmsghdr
so that we no longer need to request zeroed dataMaybeUninit
interface to initializesockaddr_storage
's