{"record":{"id":"319de2da4ebcc4bf","repo":"skylot/jadx","slug":"regions-stack-size-limit-reached","errorCode":null,"errorMessage":"Regions stack size limit reached","messagePattern":"Regions stack size limit reached","errorType":"exception","errorClass":"JadxOverflowException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/regions/maker/RegionStack.java","lineNumber":67,"sourceCode":"\t\t\treturn \"Region: \" + region + \", exits: \" + exits;\n\t\t}\n\t}\n\n\tprivate final Deque<State> stack;\n\tprivate State curState;\n\n\tpublic RegionStack(MethodNode mth) {\n\t\tif (DEBUG) {\n\t\t\tLOG.debug(\"New RegionStack: {}\", mth);\n\t\t}\n\t\tthis.stack = new ArrayDeque<>();\n\t\tthis.curState = new State();\n\t}\n\n\tpublic void push(IRegion region) {\n\t\tstack.push(curState);\n\t\tif (stack.size() > REGIONS_STACK_LIMIT) {\n\t\t\tthrow new JadxOverflowException(\"Regions stack size limit reached\");\n\t\t}\n\t\tcurState = curState.copyWith(region);\n\t\tif (DEBUG) {\n\t\t\tLOG.debug(\"Stack push: {}: {}\", size(), curState);\n\t\t}\n\t}\n\n\tpublic void pop() {\n\t\tcurState = stack.pop();\n\t\tif (DEBUG) {\n\t\t\tLOG.debug(\"Stack  pop: {}: {}\", size(), curState);\n\t\t}\n\t}\n\n\t/**\n\t * Add boundary(exit) node for current stack frame\n\t *\n\t * @param exit boundary node, null will be ignored","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/regions/maker/RegionStack.java#L49-L85","documentation":"Thrown by RegionStack.push once the region-nesting depth exceeds REGIONS_STACK_LIMIT (hard-coded 1000). RegionStack tracks the nesting of regions (loops, ifs, try/catch) during region making; exceeding 1000 levels indicates pathologically deep nesting that would otherwise overflow the JVM stack. Like 181 it is a JadxOverflowException meant to fail a single method gracefully.","triggerScenarios":"Decompiling a method whose region structure nests more than 1000 levels deep, which happens when the block graph has an extremely long chain of nested scopes (loops inside loops, ifs inside try/catch) before the maker can flatten them.","commonSituations":"Obfuscated bytecode that inserts thousands of synthetic nested scopes, generated code, or recursive-descent generated state machines. Rare in normal app code; common against hardened/packed targets.","solutions":["Upgrade jadx; region nesting has been bounded and refactored over releases.","Report the sample so the cap or the nesting logic can be revisited.","Exclude the affected method/class and continue the batch.","Catch JadxOverflowException around per-method decompilation when using jadx as a library."],"exampleFix":"// before\nJadxDecompiler d = new JadxArgs(); ... d.parseClass(...).decompile();\n// after\ntry { cls.decompile(); }\ncatch (JadxOverflowException e) { LOG.warn(\"skip {}: {}\", cls, e.getMessage()); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    cls.decompile();\n} catch (JadxOverflowException e) {\n    if (e.getMessage().contains(\"Regions stack size limit\")) {\n        cls.addError(\"region nesting too deep\", e);\n    } else { throw e; }\n}","preventionTips":["Use a larger JVM thread stack (-Xss) when embedding jadx against hardened inputs.","Catch JadxOverflowException per method so one pathological method does not abort the batch.","Report the sample; the 1000-deep cap is hard-coded and only revisited upstream."],"tags":["decompiler","regions","stack-depth","overflow","obfuscation"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}