{"record":{"id":"6458583c969a4a87","repo":"skylot/jadx","slug":"found-unreachable-blocks","errorCode":null,"errorMessage":"Found unreachable blocks","messagePattern":"Found unreachable blocks","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/blocks/DominatorTree.java","lineNumber":34,"sourceCode":" * Cooper, Keith D.; Harvey, Timothy J; Kennedy, Ken (2001).\n * \"A Simple, Fast Dominance Algorithm\"\n * http://www.hipersoft.rice.edu/grads/publications/dom14.pdf\n */\n@SuppressWarnings(\"JavadocLinkAsPlainText\")\npublic class DominatorTree {\n\n\tpublic static void compute(MethodNode mth) {\n\t\tList<BlockNode> sorted = sortBlocks(mth);\n\t\tBlockNode[] doms = build(sorted, BlockNode::getPredecessors);\n\t\tapply(sorted, doms);\n\t}\n\n\tprivate static List<BlockNode> sortBlocks(MethodNode mth) {\n\t\tint blocksCount = mth.getBasicBlocks().size();\n\t\tList<BlockNode> sorted = new ArrayList<>(blocksCount);\n\t\tBlockUtils.visitDFS(mth, sorted::add);\n\t\tif (sorted.size() != blocksCount) {\n\t\t\tthrow new JadxRuntimeException(\"Found unreachable blocks\");\n\t\t}\n\t\tmth.setBasicBlocks(sorted);\n\t\treturn sorted;\n\t}\n\n\tstatic BlockNode[] build(List<BlockNode> sorted, Function<BlockNode, List<BlockNode>> predFunc) {\n\t\tint blocksCount = sorted.size();\n\t\tBlockNode[] doms = new BlockNode[blocksCount];\n\t\tdoms[0] = sorted.get(0);\n\t\tboolean changed = true;\n\t\twhile (changed) {\n\t\t\tchanged = false;\n\t\t\tfor (int blockId = 1; blockId < blocksCount; blockId++) {\n\t\t\t\tBlockNode b = sorted.get(blockId);\n\t\t\t\tList<BlockNode> preds = predFunc.apply(b);\n\t\t\t\tint pickedPred = -1;\n\t\t\t\tBlockNode newIDom = null;\n\t\t\t\tfor (BlockNode pred : preds) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/blocks/DominatorTree.java#L16-L52","documentation":"Thrown during dominator tree construction. The algorithm requires all basic blocks to be reachable from the entry block via DFS traversal. If the DFS-visited set is smaller than the total block count, unreachable blocks remain, and the dominator algorithm (which assumes full reachability) cannot proceed safely.","triggerScenarios":"BlockUtils.visitDFS visits fewer blocks than mth.getBasicBlocks().size(). This is a post-block-processing invariant check — dead blocks should have been removed before dominator computation.","commonSituations":"A block-processing pass created or left orphaned blocks without removing them; the block cleanup pass (BlockProcessor) didn't run or didn't catch all unreachable blocks; obfuscated control flow that creates unreachable islands the cleanup doesn't recognize.","solutions":["Update jadx — this invariant is checked precisely because earlier passes occasionally miss cases","Report the APK as a jadx issue with the method that triggers it","This error indicates a bug in an earlier visitor pass; the fix is upstream","Try decompiling individual classes to isolate the trigger"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    jadxDecompiler.load();\n    jadxDecompiler.save();\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().contains(\"Found unreachable blocks\")) {\n        LOG.warn(\"Dominator tree found unreachable blocks, this is a bug in earlier passes\");\n        for (ClassNode cls : jadxDecompiler.getClasses()) {\n            try {\n                jadxDecompiler.decompileClass(cls);\n            } catch (JadxRuntimeException ex) {\n                LOG.warn(\"Skipped: {}\", cls.getFullName());\n            }\n        }\n    } else {\n        throw e;\n    }\n}","preventionTips":["Keep jadx updated — this invariant fires when earlier passes miss unreachable blocks","Report the APK as a jadx issue — this indicates a bug in block processing","Decompile classes individually to isolate which method triggers it","This is not fixable from user input; it requires a jadx code fix"],"tags":["dominator-tree","unreachable-blocks","control-flow","decompiler"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}