Skip to content
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

simplemad::Decoder<R>::decode returns Err(EOF) #31

Open
ahwatts opened this issue Nov 25, 2022 · 1 comment
Open

simplemad::Decoder<R>::decode returns Err(EOF) #31

ahwatts opened this issue Nov 25, 2022 · 1 comment

Comments

@ahwatts
Copy link

ahwatts commented Nov 25, 2022

I spent an eternity tracking this down, but on pc-windows-msvc, with simplemad 0.9.0, simplemad_sys 0.5.0, and rustc 1.67.0-nightly (c1a859b25 2022-11-10), creating a Decoder instance on a file that exists, has data, and a valid reader returns Err(EOF). I have a minimal example here:

https://github.com/ahwatts/simplemad-test

Running it against stable:

C:\Users\Andrew\Projects\simplemad-test〉rustc --version                                                                                                                                                                                                11/25/2022 01:35:45 PMrustc 1.65.0 (897e37553 2022-11-02)
C:\Users\Andrew\Projects\simplemad-test〉cargo build                                                                                                                                                                                                    11/25/2022 01:35:52 PM   Compiling gcc v0.3.55
   Compiling pkg-config v0.3.26
   Compiling libc v0.1.12
   Compiling simplemad_sys v0.5.0
   Compiling simplemad v0.9.0
   Compiling simplemad-test v0.1.0 (C:\Users\Andrew\Projects\simplemad-test)
    Finished dev [unoptimized + debuginfo] target(s) in 2.45s
C:\Users\Andrew\Projects\simplemad-test〉.\target\debug\simplemad-test.exe                                                                                                                                                                              11/25/2022 01:35:58 PM
Decoder is ok

And the output of running it with nightly:

C:\Users\Andrew\Projects\simplemad-test〉rustc +nightly --version                                                                                                                                                                                       11/25/2022 01:34:26 PMrustc 1.67.0-nightly (c1a859b25 2022-11-10)
C:\Users\Andrew\Projects\simplemad-test〉cargo +nightly build                                                                                                                                                                                           11/25/2022 01:34:38 PM   Compiling pkg-config v0.3.26
   Compiling gcc v0.3.55
   Compiling libc v0.1.12
   Compiling simplemad_sys v0.5.0
   Compiling simplemad v0.9.0
   Compiling simplemad-test v0.1.0 (C:\Users\Andrew\Projects\simplemad-test)
    Finished dev [unoptimized + debuginfo] target(s) in 2.45s
C:\Users\Andrew\Projects\simplemad-test〉.\target\debug\simplemad-test.exe                                                                                                                                                                              11/25/2022 01:34:46 PM
Decoder is not ok: Some(EOF)

It looks like the issue is here:

https://github.com/RustAudio/simplemad/blob/master/simplemad_sys/libmad-src/frame.c#L70

The variable header->layer is being initialized to 0, but 0 is not a valid enum value for enum mad_layer, which can only have 1, 2, or 3. I'm not sure why this causes Rust to freak out (but only on nightly), but changing that line in frame.c to:

  header->layer          = MAD_LAYER_I;

fixes it when running against nightly.

@ahwatts
Copy link
Author

ahwatts commented May 20, 2023

On aarch64, the same issue causes an I/O error that then causes a segfault if you try to run std::fmt::Display::fmt on it:

* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3b9aca00)
    frame #0: 0x000000010029152c organic-snout`_$LT$std..io..error..Error$u20$as$u20$core..fmt..Display$GT$::fmt::hed2bb451a324f5d8 at error.rs:944:46 [opt]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant