Skip to content

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

@ahwatts

Description

@ahwatts

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions