{"record":{"id":"28b92b16a2448a40","repo":"prestodb/presto","slug":"invalid-offset-s-and-length-s-in-array-with-s-e","errorCode":null,"errorMessage":"Invalid offset %s and length %s in array with %s elements","messagePattern":"Invalid offset (.+?) and length (.+?) in array with (.+?) elements","errorType":"validation","errorClass":"IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/block/BlockUtil.java","lineNumber":46,"sourceCode":"import static java.util.Objects.requireNonNull;\n\npublic final class BlockUtil\n{\n    private static final double BLOCK_RESET_SKEW = 1.25;\n\n    private static final int DEFAULT_CAPACITY = 64;\n    // See java.util.ArrayList for an explanation\n    static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;\n\n    private BlockUtil()\n    {\n    }\n\n    static void checkArrayRange(int[] array, int offset, int length)\n    {\n        requireNonNull(array, \"array is null\");\n        if (offset < 0 || length < 0 || offset + length > array.length) {\n            throw new IndexOutOfBoundsException(format(\"Invalid offset %s and length %s in array with %s elements\", offset, length, array.length));\n        }\n    }\n\n    static void checkArrayRange(boolean[] array, int offset, int length)\n    {\n        requireNonNull(array, \"array is null\");\n        if (offset < 0 || length < 0 || offset + length > array.length) {\n            throw new IndexOutOfBoundsException(format(\"Invalid offset %s and length %s in array with %s elements\", offset, length, array.length));\n        }\n    }\n\n    static void checkValidRegion(int positionCount, int positionOffset, int length)\n    {\n        if (positionOffset < 0 || length < 0 || positionOffset + length > positionCount) {\n            throw new IndexOutOfBoundsException(format(\"Invalid position %s and length %s in block with %s positions\", positionOffset, length, positionCount));\n        }\n    }\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/block/BlockUtil.java#L28-L64","documentation":"checkArrayRange guard: offset or length is negative or offset+length exceeds the int[] capacity, so the requested slice of the array (offsets/isNull backing arrays) is out of bounds — an internal block-util invariant violation.","triggerScenarios":"Thrown at presto-common/src/main/java/com/facebook/presto/common/block/BlockUtil.java:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate offset+length against array length before calling","Fix the caller's offset arithmetic when computing selected ranges"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}