`UnionListReader.setPosition` throws IOOBE on a post-IPC empty List

Open
#1,125 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
67/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
data

Research direction

Start with UnionListReader.setPosition and trace the calls from SingleStructReaderImpl.reader(String); compare the related UnionMapReader and UnionLargeListReader paths described in the issue. Reproduce the empty post-IPC list case, then verify that these readers no longer throw IndexOutOfBoundsException when offsets or capacity are empty or shorter than expected.

Written by the indexing model from the issue text.

Description

Type: bug
Describe the bug, including details regarding any error messages, version, and platform.

On 19.0.0 (and on master), calling setPosition on a ListVector that came off the wire via IPC with valueCount == 0 throws IndexOutOfBoundsException.

Some callers may hit this without touching setPosition themselves as

  • SingleStructReaderImpl.reader(String) calls setPosition(idx()) the first time a child reader on a struct is looked up.
  • UnionMapReader inherits from UnionListReader and breaks the same way.
  • UnionLargeListReader has a related variant; capacity guard seems to be missing and it fails whenever the offset buffer is shorter than (idx + 2) * 8 bytes.

The reader code hasn't changed. ListVector.setReaderAndWriterIndex changes and now correctly emits the leading [0] offset when valueCount == 0 (as per the Arrow spec), so the receiver's offset buffer is no longer "zero-capacity" and if block capacity() == 0 never enters.

Repro

The shape we actually hit — a struct with a list-typed child, struct itself having valueCount == 0:

StructVector parent = ...;            // child "l" is LIST<INT>, valueCount == 0
parent.getReader().reader("l");       // IOOBE
Dominant language
Java
Stars
95
Forks
154
Avg merge
2d 10h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/arrow-java

All issues in apache/arrow-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.