MuntashirAkon/AppManager · error · IOException

BZip2 CRC error

Error message

BZip2 CRC error

What it means

endBlock() compares the block's stored CRC with the computed CRC of the decompressed bytes and throws IOException("BZip2 CRC error") on mismatch. This detects that the decompressed block differs from what the compressor recorded — data corruption during decompression.

Solutions

  1. Re-download or re-extract the file from a trusted source and compare checksums.
  2. Verify with `bzip2 -tv file.bz2` before processing.
  3. If the error occurs at a known offset mid-file, recover earlier complete blocks only if you control the format (multiple concatenated streams).

Example fix

// before
process(new BZip2CompressorInputStream(new FileInputStream(bz2File)));
// after
if (!verifyBz2(bz2File)) { // runs bzip2 -tv or checks md5 against manifest
    throw new IOException("Corrupt archive: " + bz2File);
}
process(new BZip2CompressorInputStream(new FileInputStream(bz2File)));
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight integrity check (out of JVM)
// bzip2 -tv file.bz2  OR  compare stored md5/sha256 manifest

Try / catch

try {
    decompress(in);
} catch (IOException e) {
    if (String.valueOf(e.getMessage()).contains("CRC error")) {
        // mark source as corrupt; re-fetch or quarantine
        throw new DataCorruptionException(e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A compressed block whose bits were corrupted between compression and decompression; a truncated/mutated .bz2 file; memory or transfer corruption during read.

Common situations: Flaky network transfers without end-to-end checksums; failing disks; downloading .bz2 over ASCII-mode FTP that mangled bytes; corrupted attachments.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/f5810ec33a1fc449. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java:328

        // currBlockNo++;
        getAndMoveToFrontDecode();

        this.crc.initializeCRC();
        this.currentState = START_BLOCK_STATE;
    }

    private void endBlock() throws IOException {
        this.computedBlockCRC = this.crc.getFinalCRC();

        // A bad CRC is considered a fatal error.
        if (this.storedBlockCRC != this.computedBlockCRC) {
            // make next blocks readable without error
            // (repair feature, not yet documented, not tested)
            this.computedCombinedCRC = (this.storedCombinedCRC << 1)
                    | (this.storedCombinedCRC >>> 31);
            this.computedCombinedCRC ^= this.storedBlockCRC;

            throw new IOException("BZip2 CRC error");
        }

        this.computedCombinedCRC = (this.computedCombinedCRC << 1)
                | (this.computedCombinedCRC >>> 31);
        this.computedCombinedCRC ^= this.computedBlockCRC;
    }

    private boolean complete() throws IOException {
        this.storedCombinedCRC = bsGetInt(bin);
        this.currentState = EOF;
        this.data = null;

        if (this.storedCombinedCRC != this.computedCombinedCRC) {
            throw new IOException("BZip2 CRC error");
        }

        // Look for the next .bz2 stream if decompressing
        // concatenated files.

View on GitHub (pinned to 0152f468fc)