{"record":{"id":"87808ebf211f8524","repo":"skylot/jadx","slug":"expected-offset-0x-actual-0x","errorCode":null,"errorMessage":"{}, expected offset: 0x{}, actual: 0x{}","messagePattern":"(.+?), expected offset: 0x(.+?), actual: 0x(.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java","lineNumber":128,"sourceCode":"\t}\n\n\tpublic void checkInt16(int expected, String error) throws IOException {\n\t\tint v = readInt16();\n\t\tif (v != expected) {\n\t\t\tthrowException(error, expected, v);\n\t\t}\n\t}\n\n\tprivate void throwException(String error, int expected, int actual) throws IOException {\n\t\tthrow new IOException(error\n\t\t\t\t+ \", expected: 0x\" + Integer.toHexString(expected)\n\t\t\t\t+ \", actual: 0x\" + Integer.toHexString(actual)\n\t\t\t\t+ \", offset: 0x\" + Long.toHexString(getPos()));\n\t}\n\n\tpublic void checkPos(long expectedOffset, String error) throws IOException {\n\t\tif (getPos() != expectedOffset) {\n\t\t\tthrow new IOException(error + \", expected offset: 0x\" + Long.toHexString(expectedOffset)\n\t\t\t\t\t+ \", actual: 0x\" + Long.toHexString(getPos()));\n\t\t}\n\t}\n\n\tpublic void skipToPos(long expectedOffset, String error) throws IOException {\n\t\tlong pos = getPos();\n\t\tif (pos > expectedOffset) {\n\t\t\tthrow new IOException(error + \", expected offset not reachable: 0x\" + Long.toHexString(expectedOffset)\n\t\t\t\t\t+ \", actual: 0x\" + Long.toHexString(getPos()));\n\t\t}\n\t\tif (pos < expectedOffset) {\n\t\t\tskip(expectedOffset - pos);\n\t\t}\n\t\tcheckPos(expectedOffset, error);\n\t}\n\n\t@Override\n\tpublic void mark(int len) {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/xmlgen/ParserStream.java#L110-L146","documentation":"ParserStream.checkPos throws this when the current stream position does not equal a computed expected offset after parsing a chunk. This is a structural integrity check: each chunk declares its size, and after reading all fields the cursor must land exactly at chunkStart + chunkSize.","triggerScenarios":"After fully reading a chunk's fields (e.g., type spec, library), checkPos compares getPos() to expectedEndPos. A mismatch means the declared chunk size and the actual bytes consumed diverge — indicating misaligned reads, wrong field sizes, or a malformed chunk. Also called directly by skipToPos as a final assertion.","commonSituations":"Malformed or hand-crafted resources.arsc where chunkSize is inconsistent with field layout. Resource obfuscation tools that shrink entries but leave chunkSize unchanged. Newer Android format extensions jadx does not yet parse, shifting the cursor. Partial corruption of a chunk.","solutions":["Re-extract resources.arsc from the original APK to rule out corruption","Upgrade jadx to the latest release","Report to jadx with the offset from the error message for format support","As a workaround, disable resource decoding (jadx --no-res) to still decompile code"],"exampleFix":"// Disable resource decoding to bypass the parser entirely:\n// CLI:\n//   jadx --no-res app.apk\n// API:\njadxArgs.setSkipResources(true);","handlingStrategy":"try-catch","validationCode":"// No pre-validation possible without parsing; check file integrity instead\nif (Files.size(arsc) < 12) { throw new IllegalArgumentException(\"arsc too small\"); }","typeGuard":null,"tryCatchPattern":"try {\n    resTableParser.decode(stream);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"expected offset\")) {\n        LOG.warn(\"Resource structure mismatch, using --no-res\", e);\n        jadxArgs.setSkipResources(true);\n    }\n}","preventionTips":["Treat any positional validation failure as corrupt input","Provide a code-only fallback path via --no-res","Report reproducible cases to jadx maintainers"],"tags":["android","binary-parsing","validation","resource-table","corrupt-input"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}