{"record":{"id":"0591dcd04085427c","repo":"skylot/jadx","slug":"incorrect-register-number-in-instruction-expe","errorCode":null,"errorMessage":"Incorrect register number in instruction: {}, expected to be less than {}","messagePattern":"Incorrect register number in instruction: (.+?), expected to be less than (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/CheckCode.java","lineNumber":79,"sourceCode":"\t\tint regsCount = mth.getRegsCount();\n\t\tList<RegisterArg> list = new ArrayList<>();\n\t\tfor (InsnNode insnNode : mth.getInstructions()) {\n\t\t\tif (insnNode == null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlist.clear();\n\t\t\tRegisterArg resultArg = insnNode.getResult();\n\t\t\tif (resultArg != null) {\n\t\t\t\tlist.add(resultArg);\n\t\t\t}\n\t\t\tinsnNode.getRegisterArgs(list);\n\t\t\tfor (RegisterArg arg : list) {\n\t\t\t\tint regNum = arg.getRegNum();\n\t\t\t\tif (regNum < 0) {\n\t\t\t\t\tthrow new JadxRuntimeException(\"Incorrect negative register number in instruction: \" + insnNode);\n\t\t\t\t}\n\t\t\t\tif (regNum >= regsCount) {\n\t\t\t\t\tthrow new JadxRuntimeException(\"Incorrect register number in instruction: \" + insnNode\n\t\t\t\t\t\t\t+ \", expected to be less than \" + regsCount);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":61,"sourceCodeEnd":86,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/CheckCode.java#L61-L86","documentation":"Thrown by CheckCode.checkInstructions() when a register operand references a register number greater than or equal to the method's declared register count (regsCount). Valid Dalvik requires all register references to be within [0, regsCount). An out-of-bounds register indicates either corrupt bytecode or a mismatch between the register count declared in the code item and the actual instructions.","triggerScenarios":"CheckCode.visit() runs, and for some RegisterArg in an instruction, arg.getRegNum() >= regsCount (where regsCount = mth.getRegsCount()). This occurs when an instruction references a high register that was not allocated, e.g. a 16-bit register operand overflowing the register file, or a DEX where the registers_size field is too small.","commonSituations":"Obfuscated DEX files with deliberately invalid register references, DEX corruption from bad merges or transfers, or edge cases in unusual bytecode patterns (wide instructions, sparse register usage). Standard compiler output should never trigger this.","solutions":["Upgrade jadx for improved register-validation handling.","Catch JadxRuntimeException per class and continue with the rest.","Report the issue with the instruction and regsCount from the error message.","Verify the DEX integrity with dexdump/baksmali; if corrupt, obtain a clean copy."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify DEX with baksmali/dexdump before feeding to jadx\n// Command-line check (run before jadx):\n// dexdump -d input.dex > /dev/null   (exits non-zero on corruption)","typeGuard":null,"tryCatchPattern":"for (JavaClass cls : jadx.getClasses()) {\n    try {\n        cls.decompile();\n    } catch (JadxRuntimeException e) {\n        LOG.warn(\"Register OOB in {}: {}\", cls.getName(), e.getMessage());\n    }\n}","preventionTips":["Verify DEX integrity with dexdump or baksmali before decompiling.","Avoid tampered or re-serialized DEX files.","Keep jadx up to date for register-validation improvements.","Isolate failures with per-class try-catch."],"tags":["jadx","decompiler","register-validation","bytecode","dex","code-check"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}