Skip to content

Most MP3 files with meta-information fail to load #32

@MLanghof

Description

@MLanghof

#14 describes much of the same issue, but the fix for that apparently didn't resolve it completely.

This is what I get when trying to open the following files as SoundFile:

https://drive.google.com/file/d/1cNWH7bISxTRyLBPKQEA8jmgoWJSiHxSM/view?usp=sharing

london.mp3:

Caused by: java.lang.NullPointerException
	at fr.delthas.javamp3.Decoder.samples_III(Decoder.java:625)
	at fr.delthas.javamp3.Decoder.decodeFrame(Decoder.java:546)
	at fr.delthas.javamp3.Sound.decodeFullyInto(Sound.java:228)
	at processing.sound.SoundFile.<init>(Unknown Source)

close.mp3:

Caused by: java.lang.ArrayIndexOutOfBoundsException: 16
	at fr.delthas.javamp3.Decoder.samples_I(Decoder.java:1506)
	at fr.delthas.javamp3.Decoder.decodeFrame(Decoder.java:517)
	at fr.delthas.javamp3.Decoder.init(Decoder.java:431)
	at fr.delthas.javamp3.Sound.<init>(Sound.java:49)
	at processing.sound.SoundFile.<init>(Unknown Source)

noLove.mp3:

Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
	at fr.delthas.javamp3.Decoder.decodeFrame(Decoder.java:474)
	at fr.delthas.javamp3.Decoder.init(Decoder.java:431)
	at fr.delthas.javamp3.Sound.<init>(Sound.java:49)
	at processing.sound.SoundFile.<init>(Unknown Source)

The last two look suspiciously like lookups in some of the MPEG header tables (where usually the last value is illegal). All of the files have some sort of meta-information (I presume ID3 tags) preceding the real MP3 data.

The files without meta-information that I've tried seem to load fine. There are also some with meta-information that do load (presumably those where we are lucky to have no "bad" bit patterns that look like [invalid] headers in the ID3 tags).

Overall, about 80% of the files in my music library run into one of the above errors when trying to load them. I don't know whether the bug is with sound or some underlying library, but the frame parsing needs to be way more robust.

FWIW, I had extremely similar problems when I assumed that every 4 byte chunk of the byte stream that starts with the MP3 sync word (12 set bits) will be a valid header - sometimes they're not, and sometimes the bit pattern happens to indicate an invalid index into the MP3 info lookup tables. Once you "lock into" the series of headers/frames that shouldn't happen any longer but there is 0 guarantee about what is contained in the meta-info surrounding the real MP3 frames.

And for completeness: Sometimes a file may simply stop inside an MP3 frame (or there may be ID3 tag garbage after all the frames, causing similar issues to above). This file is missing a byte at the end (I didn't craft it that way, again just another file from my music library) and crashes the decoder because it's trying to read past the end:

toccata.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions