skylot/jadx · error · IOException
reading after chunk end
Error message
reading after chunk end
What it means
While iterating library entries inside a RES_TABLE_TYPE_LIBRARY chunk, the parser checks after each entry that the stream position has not exceeded the declared chunk end. If getPos() > expectedEndPos, it means a library entry read past the boundary — the count field claims more entries than the chunk can hold.
Source
Thrown at jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java:236
int entryFlag = is.readInt32();
}
if (is.getPos() != expectedEndPos) {
throw new IOException(String.format("Error reading type spec chunk at offset 0x%x", chunkStart));
}
}
private void parseLibraryTypeChunk(long chunkStart) throws IOException {
LOG.trace("parsing library type chunk starting at offset {}", chunkStart);
is.checkInt16(12, "Unexpected header size");
int chunkSize = is.readInt32();
long expectedEndPos = chunkStart + chunkSize;
int count = is.readInt32();
for (int i = 0; i < count; i++) {
int packageId = is.readInt32();
String packageName = is.readString16Fixed(128);
LOG.info("Found resource shared library {}, pkgId: {}", packageName, packageId);
if (is.getPos() > expectedEndPos) {
throw new IOException("reading after chunk end");
}
}
if (is.getPos() != expectedEndPos) {
throw new IOException(String.format("Error reading library chunk at offset 0x%x", chunkStart));
}
}
/**
* Parse an <code>ResTable_type</code> (except for the 2 bytes <code>uint16_t</code>
* from <code>ResChunk_header</code>).
*
* @see <a href=
* "https://github.com/aosp-mirror/platform_frameworks_base/blob/master/libs/androidfw/include/androidfw/ResourceTypes.h"></a>ResourceTypes.h</a>
*/
private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
/* int headerSize = */
is.readInt16();
/* int size = */View on GitHub (pinned to e738a26571)
Solutions
- Re-extract the APK from the original source
- Upgrade jadx to the latest version
- Report the APK to jadx maintainers
- Use --no-res to skip resource decoding
Example fix
// Skip resources: jadxArgs.setSkipResources(true);
Defensive patterns
Strategy: try-catch
Try / catch
try {
resTableParser.decode(stream);
} catch (IOException e) {
if (e.getMessage().contains("reading after chunk end")) {
LOG.warn("Library chunk overflow, skipping resources", e);
jadxArgs.setSkipResources(true);
}
} Prevention
- Validate APK integrity before parsing
- Use --no-res as a fallback for corrupt resources
- Keep jadx updated
When it happens
Trigger: parseLibraryTypeChunk loops count times, each iteration reading a 4-byte packageId and a 256-byte (fixed 128 char) package name. After each iteration, if is.getPos() exceeds expectedEndPos (chunkStart + chunkSize), this IOException fires. The fixed 264-byte-per-entry size makes this likely when count is too large for the declared chunkSize.
Common situations: Malformed resources.arsc with an inflated library count. Corrupt chunkSize field. APKs using shared library resource references with non-standard encoding.
Related errors
- {}, expected: 0x{}, actual: 0x{}, offset: 0x{}
- {}, expected offset: 0x{}, actual: 0x{}
- {}, expected offset not reachable: 0x{}, actual: 0x{}
- Error reading type spec chunk at offset 0x%x
- Error reading library chunk at offset 0x%x
AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14).
Data as JSON: /api/errors/b1b8e430f567f240.
Report an issue: GitHub.