{"record":{"id":"2e58abfa18ccb04f","repo":"prestodb/presto","slug":"offset-is-not-monotonically-ascending-offsets-s-2e58ab","errorCode":null,"errorMessage":"Offset is not monotonically ascending. offsets[%s]=%s, offsets[%s]=%s","messagePattern":"Offset is not monotonically ascending\\. offsets\\[(.+?)\\]=(.+?), offsets\\[(.+?)\\]=(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java","lineNumber":57,"sourceCode":"    private final long retainedSizeInBytes;\n\n    private volatile long sizeInBytes;\n    private volatile long logicalSizeInBytes;\n\n    /**\n     * Create an array block directly from columnar nulls, values, and offsets into the values.\n     * A null array must have no entries.\n     */\n    public static Block fromElementBlock(int positionCount, Optional<boolean[]> valueIsNullOptional, int[] arrayOffset, Block values)\n    {\n        boolean[] valueIsNull = valueIsNullOptional.orElse(null);\n        validateConstructorArguments(0, positionCount, valueIsNull, arrayOffset, values);\n        // for performance reasons per element checks are only performed on the public construction\n        for (int i = 0; i < positionCount; i++) {\n            int offset = arrayOffset[i];\n            int length = arrayOffset[i + 1] - offset;\n            if (length < 0) {\n                throw new IllegalArgumentException(format(\"Offset is not monotonically ascending. offsets[%s]=%s, offsets[%s]=%s\", i, arrayOffset[i], i + 1, arrayOffset[i + 1]));\n            }\n            if (valueIsNull != null && valueIsNull[i] && length != 0) {\n                throw new IllegalArgumentException(\"A null array must have zero entries\");\n            }\n        }\n        return new ArrayBlock(0, positionCount, valueIsNull, arrayOffset, values);\n    }\n\n    /**\n     * Create an array block directly without per element validations.\n     */\n    static ArrayBlock createArrayBlockInternal(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)\n    {\n        validateConstructorArguments(arrayOffset, positionCount, valueIsNull, offsets, values);\n        return new ArrayBlock(arrayOffset, positionCount, valueIsNull, offsets, values);\n    }\n\n    private static void validateConstructorArguments(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java#L39-L75","documentation":"Structural invariant check when building an ArrayBlock: the offsets array must be monotonically non-decreasing; a decreasing pair means corrupted or mis-computed offsets and the block would read negative-length arrays.","triggerScenarios":"Thrown at presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the offset computation in the producer (block builder / deserializer) to be non-decreasing","Check for int overflow when accumulating element counts"],"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"}