jbonofre opened a new issue, #1464:
URL: https://github.com/apache/arrow-java/issues/1464
### Describe the bug
Found while reviewing #1422.
1. Every `loadFieldBuffers` that loads a validity buffer
(`BaseFixedWidthVector`, `BaseVariableWidthVector`,
`BaseLargeVariableWidthVector`, `ListVector`, `LargeListVector`,
`ListViewVector`, `LargeListViewVector`, `FixedSizeListVector`, `StructVector`)
releases the vector's current validity buffer *before*
`BitVectorHelper.loadValidityBuffer` creates the new one. If that call fails,
for example with `OutOfMemoryException` while allocating a validity buffer for
a large length, the vector still points at the released buffer. Closing it
later releases the buffer again and fails with `RefCnt has gone negative`.
2. `BitVectorHelper.loadValidityBuffer` only builds a validity buffer when
the source buffer is missing *and* the null count is `0` or equal to the
length. With the "unknown" null count `-1`, which `ArrowFieldNode` accepts, a
missing buffer falls through to the "mixed" case and the source buffer is kept
as is:
- C Data: `null_count = -1` with a NULL `buffers[0]` throws a
`NullPointerException`, after (1) has already released the old buffer.
- IPC: `null_count = -1` with a 0-length validity buffer leaves the
vector with an empty validity buffer, so `isNull(i)` reads past its end.
The same fall-through happens for any null count between `1` and `length
- 1` with a missing buffer, which is invalid input.
### Expected behavior
- A failed load leaves the vector unchanged and closable.
- A missing validity buffer with null count `-1` means all values are valid,
as with null count `0`.
- A missing validity buffer is rejected with `IllegalArgumentException` when
the null count says that only some values are null.
### Component(s)
Java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]