You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Xianyang Liu (Jira)" <ji...@apache.org> on 2022/08/08 12:08:00 UTC

[jira] [Created] (ARROW-17338) [Java] The maximum request memory of BaseVariableWidthVector should limit to Interger.MAX_VALUE

Xianyang Liu created ARROW-17338:
------------------------------------

             Summary: [Java] The maximum request memory of BaseVariableWidthVector should limit to Interger.MAX_VALUE
                 Key: ARROW-17338
                 URL: https://issues.apache.org/jira/browse/ARROW-17338
             Project: Apache Arrow
          Issue Type: Bug
          Components: Java
            Reporter: Xianyang Liu


The following code of `BaseVariableWidthVector.handleSafe` could fail to relocated because of int overflow and then led to `IndexOutOfBoundsException` when we put the data into the vector.

```java
protected final void handleSafe(int index, int dataLength) {
  while (index >= getValueCapacity()) {
    reallocValidityAndOffsetBuffers();
  }
  final int startOffset = lastSet < 0 ? 0 : getStartOffset(lastSet + 1);
  // Here, the startOffset + dataLength could overflow
  while (valueBuffer.capacity() < (startOffset + dataLength)) {
    reallocDataBuffer();
  }
}
```

The offset width of `BaseVariableWidthVector` is 4, while the maximum memory allocation is  Long.MAX_VALUE. This makes the memory allocation check invalid.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)