-
Notifications
You must be signed in to change notification settings - Fork 2
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
Remove call to mem::uninitialized/zeroed inside vorbis structs #1
Conversation
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.
Test OK using FreeBSD-12 and rust-1.48.0.
Please merge. Very annoying bug. It makes life of people packaging stuff for distros really hard. |
//mem::zeroed not allowed here, so transmute from empty mem. | ||
//UB, but this needs to be initialized from C. | ||
//TODO: switch data to maybe uninit | ||
std::mem::transmute::<[u8; SIZE_OF_VORBIS], OggVorbis_File>([0u8; SIZE_OF_VORBIS]) |
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.
Suggestion: Make DecoderData
#[repr(C)]
and define a struct
#[repr(C)]
struct DecoderDataUninit<R> where R: Read + Seek {
vorbis: MaybeUninit<tremor_sys::OggVorbis_File>,
reader: R,
current_logical_bitstream: libc::c_int,
read_error: Option<io::Error>,
}
After the vorbis
field is initialized, it can be transmuted to DecoderData
.
Is this PR being made for the correct branch? The tagged release (https://github.com/librespot-org/librespot-tremor/tree/v0.1.0) doesn't belong to any branch in this repository. |
I created another PR (#2) based on this one, which has probably a more sound use of |
This is the correct branch. I just pushed the commits. I must have somehow uploaded the tags without the commits. Thanks for spotting that.
Closing in favour of PR #2 |
As of the latest rustc 1.48.0,
Decoder::<R>::new()
panics at runtime with the errorThis PR adds a
close_func
no-op to fill outov_callbacks
and changesDecoderData
to usemem::transmute
. This needs a review, but it does build and run locally.fixes spotifyd issue Spotifyd/spotifyd/issues/719