Skip to content

Return errors for JSON reader allocation overflows - #12494

Open
umrndem wants to merge 1 commit into
apache:mainfrom
umrndem:codex/json-reader-capacity-bounds
Open

umrndem wants to merge 1 commit into
apache:mainfrom
umrndem:codex/json-reader-capacity-bounds

Conversation

@umrndem

@umrndem umrndem commented Nov 29, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Part of #12325.

Rationale for this change

Oversized batch sizes and negative fixed-size widths can panic when constructing or flushing a JSON reader. On 32-bit targets, an element count can fit in usize while its allocation size exceeds Vec's limit.

What changes are included in this PR?

Check tape preallocation estimates and fixed-size list/binary capacity products before allocation. Validate negative widths before they reach the builders, and check the struct field-position buffer's allocation layout before clearing its previous contents.

This covers reader initialization and fixed-size allocation sizing. The remaining tape-index representation and coercion paths are outside this patch's scope. No public signatures change.

Are these changes tested?

Adds regressions through both ReaderBuilder entry points, including empty schemas and negative fixed-size widths. The 32-bit tests cover overflowing products, allocation-layout limits and preservation of the reusable struct-position buffer after an error.

Are there any significant user-facing changes?

No.

AI usage disclosure

AI helped prepare the patch and regression tests.

@boring-cyborg boring-cyborg Bot added the arrow-json arrow-json crate label Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow-json arrow-json crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant