skylot/jadx · error · JadxRuntimeException
Incorrect register number in instruction: {}, expected to be
Error message
Incorrect register number in instruction: {}, expected to be less than {} What it means
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.
Source
Thrown at jadx-core/src/main/java/jadx/core/dex/visitors/CheckCode.java:79
int regsCount = mth.getRegsCount();
List<RegisterArg> list = new ArrayList<>();
for (InsnNode insnNode : mth.getInstructions()) {
if (insnNode == null) {
continue;
}
list.clear();
RegisterArg resultArg = insnNode.getResult();
if (resultArg != null) {
list.add(resultArg);
}
insnNode.getRegisterArgs(list);
for (RegisterArg arg : list) {
int regNum = arg.getRegNum();
if (regNum < 0) {
throw new JadxRuntimeException("Incorrect negative register number in instruction: " + insnNode);
}
if (regNum >= regsCount) {
throw new JadxRuntimeException("Incorrect register number in instruction: " + insnNode
+ ", expected to be less than " + regsCount);
}
}
}
}
}
View on GitHub (pinned to e738a26571)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify DEX with baksmali/dexdump before feeding to jadx // Command-line check (run before jadx): // dexdump -d input.dex > /dev/null (exits non-zero on corruption)
Try / catch
for (JavaClass cls : jadx.getClasses()) {
try {
cls.decompile();
} catch (JadxRuntimeException e) {
LOG.warn("Register OOB in {}: {}", cls.getName(), e.getMessage());
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Incorrect negative register number in instruction: {}
- Bad name for type variable: {}
- Can't parse type: {}, unexpected: {}
- Invalid args count in insn: {}
- Null array element type
AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14).
Data as JSON: /api/errors/0591dcd04085427c.
Report an issue: GitHub.