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

  1. Upgrade jadx for improved register-validation handling.
  2. Catch JadxRuntimeException per class and continue with the rest.
  3. Report the issue with the instruction and regsCount from the error message.
  4. 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

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


AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14). Data as JSON: /api/errors/0591dcd04085427c. Report an issue: GitHub.