{"record":{"id":"5048af5bd1c0fab3","repo":"skylot/jadx","slug":"regions-count-limit-reached-at-block","errorCode":null,"errorMessage":"Regions count limit reached at block {}","messagePattern":"Regions count limit reached at block (.+?)","errorType":"exception","errorClass":"JadxOverflowException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/regions/maker/RegionMaker.java","lineNumber":72,"sourceCode":"\t\tRegion region = new Region(stack.peekRegion());\n\t\tif (stack.containsExit(startBlock)) {\n\t\t\tinsertEdgeInsns(region, startBlock);\n\t\t\treturn region;\n\t\t}\n\t\tif (processedBlocks.addChecked(startBlock)) {\n\t\t\t// Add block to multiple regions (duplicate the instructions in decompiled code)\n\t\t\t// and allow processing to continue\n\t\t\tif (!startBlock.contains(AFlag.DUPLICATED)) {\n\t\t\t\tmth.addWarnComment(\"Code duplicated, block: \" + startBlock + ' ' + startBlock.getAttributesString());\n\t\t\t\tstartBlock.add(AFlag.DUPLICATED);\n\t\t\t}\n\t\t}\n\t\tBlockNode next = startBlock;\n\t\twhile (next != null) {\n\t\t\tnext = traverse(region, next);\n\t\t\tregionsCount++;\n\t\t\tif (regionsCount > regionsLimit) {\n\t\t\t\tthrow new JadxOverflowException(\"Regions count limit reached at block \" + startBlock);\n\t\t\t}\n\t\t}\n\t\treturn region;\n\t}\n\n\t/**\n\t * Recursively traverse all blocks from 'block' until block from 'exits'\n\t */\n\tprivate @Nullable BlockNode traverse(Region r, BlockNode block) {\n\t\tif (block.contains(AFlag.MTH_EXIT_BLOCK)) {\n\t\t\treturn null;\n\t\t}\n\t\tBlockNode next = null;\n\t\tboolean processed = false;\n\n\t\tList<LoopInfo> loops = block.getAll(AType.LOOP);\n\t\tint loopCount = loops.size();\n\t\tif (loopCount != 0 && block.contains(AFlag.LOOP_START)) {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/regions/maker/RegionMaker.java#L54-L90","documentation":"Thrown by RegionMaker.makeRegion when the block-traversal loop produces more than regionsLimit (basicBlocks.size() * 400) regions for a single method. It guards region construction against pathological control-flow explosion that would otherwise exhaust memory or run for minutes. A JadxOverflowException, so it is meant to be catchable and to fail one method, not the whole run.","triggerScenarios":"Decompiling a method whose CFG, after block merging, causes traverse() to keep returning non-null next blocks and accumulate regions beyond 400 * basicBlocks.size(). Typical of generated state-machine code, huge switch ladders, or methods flattened by obfuscators.","commonSituations":"Obfuscated apps, methods decompiled from native-to-DEX translators, auto-generated lookup tables encoded as switch/if chains, or methods with many duplicated blocks (the DUPLICATED path above this check is what usually precedes the blow-up).","solutions":["Update jadx; the multiplier and traversal have been tuned repeatedly.","Report the input with the method name so the region-maker logic can be improved.","Decompile the class with the method excluded, or run with the CLI/GUI 'skip errors' style flow that records the failure as a method warning instead of aborting.","If embedding jadx, catch JadxOverflowException per class/method."],"exampleFix":"// before\nClassNode cls = ...;\nnew RegionMaker(cls).makeMthRegion();\n// after\ntry {\n    new RegionMaker(cls).makeMthRegion();\n} catch (JadxOverflowException e) {\n    cls.addError(\"region build overflow\", e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    cls.decompile();\n} catch (JadxOverflowException e) {\n    cls.addError(\"region count overflow\", e);\n}","preventionTips":["Treat JadxOverflowException as 'skip this method, keep going'.","Surface method-level errors to the user instead of aborting a batch run.","Report inputs that trigger this so the 400x multiplier or traversal can be revisited."],"tags":["decompiler","regions","overflow","obfuscation","control-flow"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}