can1357/oh-my-pi · error · ArchiveError

Invalid CAB archive: LZX match crosses a frame or block boun

Error message

Invalid CAB archive: LZX match crosses a frame or block boundary

What it means

A decoded LZX match would produce more bytes than remain in the current block or frame. LZX never allows matches to span block/frame boundaries, so such a match proves the bitstream is corrupt.

Source

Thrown at packages/utils/src/ar/codecs/lzx.ts:285

		}
		if (!this.#mainTable || !this.#lengthTable)
			throw new ArchiveError("Invalid CAB archive: missing LZX decode trees");

		let produced = 0;
		while (produced < count) {
			const element = this.#mainTable.decode(reader);
			if (element < 256) {
				this.#writeByte(element, output, outputStart + produced);
				produced++;
				continue;
			}

			const match = element - 256;
			let matchLength = match & NUM_PRIMARY_LENGTHS;
			if (matchLength === NUM_PRIMARY_LENGTHS) matchLength += this.#lengthTable.decode(reader);
			matchLength += MIN_MATCH;
			if (matchLength > count - produced || matchLength > this.#blockRemaining - produced) {
				throw new ArchiveError("Invalid CAB archive: LZX match crosses a frame or block boundary");
			}

			const slot = match >>> 3;
			let matchOffset: number;
			if (slot === 0) {
				matchOffset = this.#r0;
			} else if (slot === 1) {
				matchOffset = this.#r1;
				this.#r1 = this.#r0;
				this.#r0 = matchOffset;
			} else if (slot === 2) {
				matchOffset = this.#r2;
				this.#r2 = this.#r0;
				this.#r0 = matchOffset;
			} else {
				if (slot >= this.#positionBase.byteLength)
					throw new ArchiveError("Invalid CAB archive: LZX position slot is out of range");
				const extra = this.#extraBits[slot]!;

View on GitHub (pinned to 9690622007)

Solutions

  1. Verify archive integrity (CRC/checksum on the CAB).
  2. Re-extract the file; if reproducible, the file is corrupt at the source.
  3. Stop decoding this stream — recovery mid-frame is not possible.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const out = decompressFrame(frame);
} catch (err) {
  if (err instanceof ArchiveError && err.message.includes("crosses a frame or block boundary")) {
    // corrupt stream — abort extraction of this folder
  } else throw err;
}

Prevention

When it happens

Trigger: decompressFrame -> #decodeRun decodes a match whose matchLength exceeds the requested count or the block's remaining byte budget (#blockRemaining).

Common situations: Corrupted CAB data, bit-reader desync from earlier errors, fuzzed archives.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/5b56b1b6780a5664. Report an issue: GitHub.