TeamNewPipe/NewPipe · error · EOFException

parser go beyond limits of the Element. type=%s offset=%s si

Error message

parser go beyond limits of the Element. type=%s offset=%s size=%s position=%s

What it means

WebMReader.ensure(ref) computes how many bytes remain to the end of the current element (ref.offset + ref.size - stream.position()). A negative skip means the parser already read past the element's declared boundary — a sub-parser consumed more bytes than the element allows, indicating corrupt or inconsistent EBML sizes. EOFException reports type/offset/size/position.

Source

Thrown at app/src/main/java/org/schabi/newpipe/streams/WebMReader.java:219

            }

            ensure(elem);
        }

        return null;
    }

    private String elementID(final long type) {
        return "0x".concat(Long.toHexString(type));
    }

    private void ensure(final Element ref) throws IOException {
        final long skip = (ref.offset + ref.size) - stream.position();

        if (skip == 0) {
            return;
        } else if (skip < 0) {
            throw new EOFException(String.format(
                    "parser go beyond limits of the Element. type=%s offset=%s size=%s position=%s",
                    elementID(ref.type), ref.offset, ref.size, stream.position()
            ));
        }

        stream.skipBytes(skip);
    }

    private boolean readEbml(final Element ref, final int minReadVersion,
                             final int minDocTypeVersion) throws IOException {
        Element elem = untilElement(ref, ID_EMBL_READ_VERSION);
        if (elem == null) {
            return false;
        }
        if (readNumber(elem) > minReadVersion) {
            return false;
        }

View on GitHub (pinned to 9e8be09156)

Solutions

  1. Re-download or re-mux; nested element sizes are internally inconsistent.
  2. Validate with mkvinfo/ffprobe which reports structural inconsistencies.
  3. If you produce the files, audit nested size computation so children never exceed parent extents.
  4. Treat as fatal for the current cluster and skip forward to the next Cluster ID if resilience is needed.

Example fix

// before — sub-parser overruns parent element and trips ensure()
parseChildren(elem); // reads past elem.size

// after — bound child reads by the parent element limit
long limit = elem.offset + elem.size;
while (stream.position() < limit) { parseChild(elem); }
Defensive patterns

Strategy: validation

Validate before calling

// Producer-side: ensure sub-parsers never read past the parent element boundary.
long parentEnd = elem.offset + elem.size;
while (stream.position() < parentEnd) {
    parseChild(elem, parentEnd); // pass limit, clamp child reads
}

Type guard

public static boolean childWithinParent(long childEnd, long parentEnd) {
    return childEnd <= parentEnd;
}

Try / catch

try {
    ensure(elem);
} catch (EOFException e) {
    if (e.getMessage().contains("beyond limits")) {
        // parser overran the element — skip forward to the next Cluster
        Log.w(TAG, "element overrun: " + e.getMessage());
        skipToNextCluster();
    } else throw e;
}

Prevention

When it happens

Trigger: Any ensure(ref) call after parsing element children where the child content exceeded the parent element's declared content size. The parent's size is smaller than what its children occupy, or a child's length overran.

Common situations: A malformed WebM with an undersized element size relative to its content; a corrupted Block/Cluster whose length fields are inconsistent; a tampered file; a muxer bug producing inconsistent nested sizes.

Related errors


AI-assisted analysis of TeamNewPipe/NewPipe@9e8be09156 (2026-08-14). Data as JSON: /api/errors/b792d0c39fec0854. Report an issue: GitHub.