{"record":{"id":"4a2e84ad98852d76","repo":"skylot/jadx","slug":"invalid-args-count-in-insn","errorCode":null,"errorMessage":"Invalid args count in insn: {}","messagePattern":"Invalid args count in insn: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java","lineNumber":361,"sourceCode":"\t\t\tString s = ((ConstStringNode) insn).getString();\n\t\t\tf = parentClass.getConstField(s);\n\t\t} else if (insn.getType() == InsnType.CONST_CLASS) {\n\t\t\tArgType t = ((ConstClassNode) insn).getClsType();\n\t\t\tf = parentClass.getConstField(t);\n\t\t} else {\n\t\t\tf = parentClass.getConstFieldByLiteralArg((LiteralArg) insn.getArg(0));\n\t\t}\n\t\tif (f != null) {\n\t\t\tInsnNode inode = new IndexInsnNode(InsnType.SGET, f.getFieldInfo(), 0);\n\t\t\tinode.setResult(insn.getResult());\n\t\t\treplaceInsn(mth, block, i, inode);\n\t\t\taddFieldUsage(f, mth);\n\t\t}\n\t}\n\n\tprivate static void processArith(MethodNode mth, ClassNode parentClass, ArithNode arithNode) {\n\t\tif (arithNode.getArgsCount() != 2) {\n\t\t\tthrow new JadxRuntimeException(\"Invalid args count in insn: \" + arithNode);\n\t\t}\n\t\tInsnArg litArg = arithNode.getArg(1);\n\t\tif (litArg.isLiteral()) {\n\t\t\tIFieldInfoRef f = parentClass.getConstFieldByLiteralArg((LiteralArg) litArg);\n\t\t\tif (f != null) {\n\t\t\t\tInsnNode fGet = new IndexInsnNode(InsnType.SGET, f.getFieldInfo(), 0);\n\t\t\t\tif (arithNode.replaceArg(litArg, InsnArg.wrapArg(fGet))) {\n\t\t\t\t\taddFieldUsage(f, mth);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Inline CMP instructions into 'if' to help conditions merging\n\t */\n\tprivate static void inlineCMPInsns(MethodNode mth, BlockNode block, int i, InsnNode insn, InsnRemover remover) {\n\t\tRegisterArg resArg = insn.getResult();","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java#L343-L379","documentation":"Thrown by ModVisitor.processArith() when an ArithNode instruction does not have exactly 2 arguments. Arithmetic operations in Dalvik (and in jadx's IR) are binary — they always have a result and two source operands (e.g. a = b + c). An ArithNode with a different arg count indicates the instruction was constructed incorrectly.","triggerScenarios":"processArith() receives an ArithNode from the instruction list and checks arithNode.getArgsCount() != 2. This means the ArithNode was built with 0, 1, or 3+ arguments — an invariant violation from the instruction decoder or a prior visitor that malformed the node.","commonSituations":"Rare; usually indicates a jadx internal bug in instruction construction or a corrupt DEX that produces a malformed arithmetic instruction. Not expected from standard compiler output. May appear after a jadx upgrade that changes ArithNode construction.","solutions":["Upgrade jadx or check for regressions if already on latest.","Catch JadxRuntimeException per class and skip the offending method.","Report the issue with the ArithNode toString() from the error — likely a jadx bug.","Verify the DEX integrity; if corrupt, obtain a clean copy."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    javaClass.decompile();\n} catch (JadxRuntimeException e) {\n    LOG.warn(\"Invalid arith insn in {}: {}\", javaClass.getName(), e.getMessage());\n}","preventionTips":["Upgrade jadx or check for regressions — ArithNode arg-count violations are internal bugs.","Catch per class to isolate the failure.","Report the ArithNode dump from the error message.","Verify DEX integrity; if corrupt, obtain a clean copy."],"tags":["jadx","decompiler","arithmetic","instruction-validation","internal-bug","bytecode"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}