[Java][JDBC] ClobConsumer writes past VarCharVector data buffer for large CLOBs
- Linguagem predominante
- Java
- Estrelas
- 94
- Forks
- 152
- Merge médio
- 3d 16h
- PRs com merge (30d)
- 11
Descrição
ClobConsumer copies CLOB data into the VarCharVector data buffer with `MemoryUtil.copyToMemory` at offset `startIndex + totalBytes`, but the buffer-growth guard checks `dataBuffer.writerIndex() + bytes.length > dataBuffer.capacity()`. `copyToMemory` never advances `writerIndex()`, and nothing else does either, so it stays at 0 and the guard only ever checks that a single chunk fits at offset 0. Once the cumulative bytes of a CLOB (or a batch of CLOB rows) exceed the initial data-buffer allocation of about 32 KB, `reallocDataBuffer()` is never called and `copyToMemory`, which performs no ArrowBuf bounds checking, writes past the allocation into adjacent off-heap memory.
The sibling `BinaryConsumer` uses the correct check: `while (vector.getDataBuffer().capacity() < (startOffset + dataLength + read))`.
To reproduce, consume a single CLOB whose UTF-8 length exceeds the initial data buffer (for example `INITIAL_VALUE_ALLOCATION * 8 * 4` characters). The out-of-bounds write corrupts the adjacent offset buffer, and reading the value back throws `NegativeArraySizeException`.
Guia de contribuição
Direção de pesquisa
Localize ClobConsumer e compare sua proteção contra o crescimento do buffer de dados de VarCharVector com a verificação correspondente de BinaryConsumer. Reproduza o problema com um CLOB cujos dados UTF-8 excedam a alocação inicial e, em seguida, verifique se os dados cumulativos do CLOB ou do batch não corrompem o buffer de offsets e podem ser lidos novamente com sucesso.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- java
- Domínio
- backend, database
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Pouca atividade
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 78/100