OutOfMemoryError while extracting tags from a file

Issue #52 resolved
Former user created an issue

Hi,

We are using JAudioTagger to extract tags from mp3s. Recently we came across one file for which an OutOfMemoryError is thrown when we are trying to extract. This issue is consistent and happens every time with that particular file.

The version of the library we normally use is 2.0.4, but we tried with the latest one (2.2.2) and the symptoms were the same.

The way we call your library is

AudioFileIO.read(audio);

where audio in an instance of java.io.File.

Here is the portion of the stack trace:

java.lang.OutOfMemoryError: Java heap space
    at org.jaudiotagger.tag.id3.framebody.AbstractID3v2FrameBody.read(AbstractID3v2FrameBody.java:155)
    at org.jaudiotagger.tag.id3.framebody.AbstractID3v2FrameBody.<init>(AbstractID3v2FrameBody.java:81)
    at org.jaudiotagger.tag.id3.framebody.FrameBodyCOMM.<init>(FrameBodyCOMM.java:143)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.jaudiotagger.tag.id3.AbstractID3v2Frame.readBody(AbstractID3v2Frame.java:272)
    at org.jaudiotagger.tag.id3.ID3v23Frame.read(ID3v23Frame.java:433)
    at org.jaudiotagger.tag.id3.ID3v23Frame.<init>(ID3v23Frame.java:280)
    at org.jaudiotagger.tag.id3.ID3v23Tag.readFrames(ID3v23Tag.java:578)
    at org.jaudiotagger.tag.id3.ID3v23Tag.read(ID3v23Tag.java:543)
    at org.jaudiotagger.tag.id3.ID3v23Tag.<init>(ID3v23Tag.java:308)
    at org.jaudiotagger.audio.mp3.MP3File.readV2Tag(MP3File.java:225)
    at org.jaudiotagger.audio.mp3.MP3File.<init>(MP3File.java:466)
    at org.jaudiotagger.audio.mp3.MP3FileReader.read(MP3FileReader.java:39)
    at org.jaudiotagger.audio.AudioFileIO.readFile(AudioFileIO.java:288)
    at org.jaudiotagger.audio.AudioFileIO.read(AudioFileIO.java:151)

The file that causes failures is attached. Could you please check this issue and fix if possible?

Thank you

Comments (6)

  1. IJabz repo owner

    Had a quick look COMM frame is marked as encrypted and compressed and its size header indicates its very large causing memory error when space is allocated to read it in, but it isnt really very large, unclear if actually compressed/encrypted.

  2. IJabz repo owner

    so the frame header bytes is 11000010, (0xC2) that last 1 is not a valid flag it should always be zero, the first bytes indicates compressed, the second encrypted. But looking at the raw data data size is set to 5 and its looks like there is only 5 bytes of data before a small corruption, there is no ENCR frame so I don't think it is actually encrypted either. So the task is to just better handle these corrupt frames.

  3. IJabz repo owner

    Found another issue, we handle a compressed frame, and we handle an encrypted frame but we dont handle a compressed AND encrypted frame. Fixing this happens to allow this file to be loaded but this is more coincidental, what we should additionally do is check the encoding bytes and if we have bytes that shoud not be set (bytes 3-7) then treat frame as uncompressed, unencrypted because probably corrupted

  4. IJabz repo owner

    Decided thats its 50/50 if if have other encoding bytes enabled, so instead added some sanity checks to detect invalid frames

  5. Log in to comment