{"record":{"id":"6fd1fc0999619a7b","repo":"skylot/jadx","slug":"block-not-found-by-insn","errorCode":null,"errorMessage":"Block not found by insn: {}","messagePattern":"Block not found by insn: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/ConstructorVisitor.java","lineNumber":131,"sourceCode":"\t}\n\n\tprivate static @Nullable ArgType searchInstanceType(InvokeNode inv) {\n\t\tInsnArg instanceArg = inv.getInstanceArg();\n\t\tif (instanceArg == null || !instanceArg.isRegister()) {\n\t\t\treturn null;\n\t\t}\n\t\tInsnNode assignInsn = ((RegisterArg) instanceArg).getSVar().getAssignInsn();\n\t\tif (assignInsn == null || assignInsn.getType() != InsnType.NEW_INSTANCE) {\n\t\t\treturn null;\n\t\t}\n\t\treturn ((IndexInsnNode) assignInsn).getIndexAsType();\n\t}\n\n\tprivate static RegisterArg insertPhiInsn(MethodNode mth, BlockNode curBlock,\n\t\t\tRegisterArg instArg, ConstructorInsn otherCtr) {\n\t\tBlockNode otherBlock = BlockUtils.getBlockByInsn(mth, otherCtr);\n\t\tif (otherBlock == null) {\n\t\t\tthrow new JadxRuntimeException(\"Block not found by insn: \" + otherCtr);\n\t\t}\n\t\tBlockNode crossBlock = BlockUtils.getPathCross(mth, curBlock, otherBlock);\n\t\tif (crossBlock == null) {\n\t\t\t// no path cross => PHI insn not needed\n\t\t\t// use new SSA var on usage from current path\n\t\t\tRegisterArg newResArg = instArg.duplicateWithNewSSAVar(mth);\n\t\t\tList<BlockNode> pathBlocks = BlockUtils.collectAllSuccessors(mth, curBlock, true);\n\t\t\tfor (RegisterArg useReg : instArg.getSVar().getUseList()) {\n\t\t\t\tInsnNode parentInsn = useReg.getParentInsn();\n\t\t\t\tif (parentInsn != null) {\n\t\t\t\t\tBlockNode useBlock = BlockUtils.getBlockByInsn(mth, parentInsn, pathBlocks);\n\t\t\t\t\tif (useBlock != null) {\n\t\t\t\t\t\tparentInsn.replaceArg(useReg, newResArg.duplicate());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn newResArg;\n\t\t}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/ConstructorVisitor.java#L113-L149","documentation":"Thrown by ConstructorVisitor.insertPhiInsn() when BlockUtils.getBlockByInsn() cannot find the basic block containing a given ConstructorInsn. This method builds a PHI node at the path-cross of two blocks (the current block and the block of another constructor call); if the other constructor's block cannot be located, the SSA/PHI construction cannot proceed and jadx aborts.","triggerScenarios":"insertPhiInsn() is called with a ConstructorInsn otherCtr that was expected to exist in the method's CFG. BlockUtils.getBlockByInsn(mth, otherCtr) returns null — the instruction is not found in any block, perhaps because it was already removed or moved by a prior visitor pass, or because the CFG is inconsistent.","commonSituations":"Complex constructor patterns with branching (e.g. constructors called conditionally across multiple paths), often in decompiled enum or builder-pattern code. Can also arise from ordering issues between visitor passes where an instruction is referenced after removal.","solutions":["Upgrade jadx — constructor-visitor and CFG consistency are regularly improved.","Catch JadxRuntimeException per method/class and continue.","Report the issue with the constructor instruction and method context.","Try disabling related optimizations or using conservative decompiler settings."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    javaClass.decompile();\n} catch (JadxRuntimeException e) {\n    LOG.warn(\"Constructor PHI construction failed in {}: {}\", javaClass.getName(), e.getMessage());\n}","preventionTips":["Upgrade jadx for CFG and constructor-visitor fixes.","Isolate per-class with try-catch.","Report complex constructor patterns that trigger the error.","Try conservative decompiler settings if the class is critical."],"tags":["jadx","decompiler","constructor","phi-node","cfg","ssa"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}