{"record":{"id":"9711aa824a1dc61b","repo":"skylot/jadx","slug":"attempted-to-get-instructions-slice-of-block-wi","errorCode":null,"errorMessage":"Attempted to get instructions slice of block {} with {} skipped instructions whilst only having {} instructions in block.","messagePattern":"Attempted to get instructions slice of block (.+?) with (.+?) skipped instructions whilst only having (.+?) instructions in block\\.","errorType":"exception","errorClass":"IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/finaly/traverser/state/TraverserBlockInfo.java","lineNumber":79,"sourceCode":"\t}\n\n\tpublic void setBottomOffset(int bottomOffset) {\n\t\tthis.bottomOffset = bottomOffset;\n\t}\n\n\tpublic int getBottomImplicitCount() {\n\t\treturn bottomImplicitCount;\n\t}\n\n\tpublic void setBottomImplicitOffset(int bottomImplicitCount) {\n\t\tthis.bottomImplicitCount = bottomImplicitCount;\n\t}\n\n\tpublic List<InsnNode> getInsnsSlice() {\n\t\tList<InsnNode> insns = block.getInstructions();\n\t\tint totalSkippedCount = bottomOffset + topOffset;\n\t\tif (totalSkippedCount > insns.size()) {\n\t\t\tthrow new IndexOutOfBoundsException(\"Attempted to get instructions slice of block \" + block.toString() + \" with \"\n\t\t\t\t\t+ totalSkippedCount + \" skipped instructions whilst only having \" + insns.size() + \" instructions in block.\");\n\t\t}\n\t\tint startIndex = topOffset;\n\t\tint endIndex = insns.size() - bottomOffset;\n\t\treturn insns.subList(startIndex, endIndex);\n\t}\n}\n","sourceCodeStart":61,"sourceCodeEnd":87,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/finaly/traverser/state/TraverserBlockInfo.java#L61-L87","documentation":"Thrown as IndexOutOfBoundsException by TraverserBlockInfo.getInsnsSlice() when the sum of bottomOffset and topOffset exceeds the block's total instruction count. The block info tracks how many instructions to skip from the top (entry) and bottom (exit) of a block to produce the 'active' instruction window. If these offsets are inflated beyond the block's instruction list size, the slice computation is impossible.","triggerScenarios":"bottomOffset or topOffset was set (via setBottomOffset/setTopOffset) to values whose sum exceeds block.getInstructions().size(). This occurs when a visitor computes offsets based on a stale or modified instruction list, or when implicit-instruction accounting (bottomImplicitCount) interacts incorrectly with explicit offsets.","commonSituations":"Decompiling bytecode where a block's instructions were mutated or removed by a prior visitor pass after the TraverserBlockInfo was created. Also possible with empty blocks or blocks reduced to zero instructions by dead-code elimination while offsets remain non-zero.","solutions":["Report to jadx developers with the input and stack trace, noting the block and offset values in the message.","Workaround: disable the finally extraction pass.","If developing jadx, add a precondition check in setBottomOffset/setTopOffset that rejects values exceeding the block instruction count, and audit ImplicitInsnBlockTraverserVisitor and PathEndBlockTraverserVisitor for stale instruction-list assumptions."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"List<InsnNode> insns = block.getInstructions();\nint totalSkipped = bottomOffset + topOffset;\nif (totalSkipped > insns.size()) {\n    // Offsets exceed block size; clamp or reset before calling getInsnsSlice()\n    return Collections.emptyList();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["If developing jadx, validate offsets in setBottomOffset/setTopOffset against the current instruction count.","Ensure instruction lists are not mutated after TraverserBlockInfo creation, or invalidate offsets on mutation.","Report inputs that trigger this with the block and offset values from the error message."],"tags":["jadx","decompiler","finally-traverser","index-out-of-bounds","offset-overflow"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}