{"record":{"id":"7eb2ad95bc3c35b1","repo":"pxb1988/dex2jar","slug":"jump-out-of-insns-s-04x","errorCode":null,"errorMessage":"jump out of insns %s -> %04x","messagePattern":"jump out of insns (.+?) -> %04x","errorType":"exception","errorClass":"BadOpException","httpStatus":null,"severity":"error","filePath":"dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java","lineNumber":1163,"sourceCode":"\r\n    private void travelInsn(Map<Integer, DexLabel> labelsMap, Queue<Integer> q, byte[] insns, int offset) {\r\n        int u1offset = offset * 2;\r\n        if (u1offset >= insns.length) {\r\n            throw new IndexOutOfBoundsException();\r\n        }\r\n        int opcode = 0xFF & insns[u1offset];\r\n        Op op = Op.ops[opcode];\r\n        if (op == null || op.format == null) {\r\n            throw new BadOpException(\"zero-width instruction op=0x%02x\", opcode);\r\n        }\r\n        int target;\r\n        boolean canContinue = true;\r\n        if (op.canBranch()) {\r\n            switch (op.format) {\r\n            case kFmt10t:\r\n                target = offset + insns[u1offset + 1];\r\n                if (target < 0 || target * 2 > insns.length ) {\r\n                    throw new BadOpException(\"jump out of insns %s -> %04x\", op, target);\r\n                }\r\n                q.add(target);\r\n                order(labelsMap, target);\r\n                break;\r\n            case kFmt20t:\r\n            case kFmt21t:\r\n                target = offset + sshort(insns, u1offset + 2);\r\n                if (target < 0 || target * 2 > insns.length ) {\r\n                    throw new BadOpException(\"jump out of insns %s -> %04x\", op, target);\r\n                }\r\n                q.add(target);\r\n                order(labelsMap, target);\r\n                break;\r\n            case kFmt22t:\r\n                target = offset + sshort(insns, u1offset + 2);\r\n\r\n                int u = ubyte(insns, u1offset + 1);\r\n                boolean cmpSameReg = (u & 0x0F) == ((u >> 4) & 0x0F);\r","sourceCodeStart":1145,"sourceCodeEnd":1181,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java#L1145-L1181","documentation":"BadOpException thrown during code traversal when a kFmt10t (10-bit) branch instruction computes a jump target that is negative or beyond the end of the insns array. Such a target cannot be labeled, so the bytecode is deemed malformed.","triggerScenarios":"Opcode walker hits a kFmt10t op whose signed byte displacement makes target = offset + insns[u1offset+1] satisfy target < 0 || target*2 > insns.length.","commonSituations":"Corrupted or truncated dex code items, junk-injected obfuscated bytecode, or dexes patched by tools that don't fix up branch displacements.","solutions":["Disassemble the method with baksmali to inspect the branching instruction","Rebuild the dex with dx/d8 to regenerate valid branch offsets","Update d2j; some versions fixed off-by-one boundary checks","Catch BadOpException around accept() to skip the broken method"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Caller-side sanity check on code item size before traversal\nif (codeItem.insns == null || codeItem.insns.length == 0) throw new IllegalStateException(\"empty insns\");","typeGuard":null,"tryCatchPattern":"try {\n    reader.accept(dmv);\n} catch (DexException e) {\n    if (e.getCause() instanceof BadOpException) log.warn(\"bad branch target, method skipped\");\n}","preventionTips":["Rebuild dexes with dx/d8 rather than patching bytecode by hand","Check APK/dex integrity (MD5/CRC) after download or extraction","Treat obfuscated junk-injected dexes as unconvertible"],"tags":["dex","bytecode","branch-target","malformed-input"],"backgroundTag":"value-out-of-range","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}