Skip to content

fix(backport): prevent array_resize capacity overflow panic - #15

Open
discord9 wants to merge 1 commit into
GreptimeTeam:greptimedb-53.1.0-function-signature-exec-errorfrom
discord9:fix/qp-023-array-resize-panic
Open

fix(backport): prevent array_resize capacity overflow panic#15
discord9 wants to merge 1 commit into
GreptimeTeam:greptimedb-53.1.0-function-signature-exec-errorfrom
discord9:fix/qp-023-array-resize-panic

Conversation

@discord9

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

array_resize(make_array(1), 9223372036854775807, 0) panics while creating the physical plan on the GreptimeDB DataFusion 53.1 fork. Oversized resize requests should return a controlled execution error instead of aborting query planning.

What changes are included in this PR?

  • Preflight cumulative output lengths before materializing fill values or allocating Arrow buffers.
  • Reject totals that overflow the list offset type or Arrow 58 eager buffer capacities, including alignment and nested-capacity constraints.
  • Preserve the fork's existing NULL-count and row-specific fill behavior while replacing target-derived unchecked offset arithmetic.
  • Add allocation-safe unit coverage plus an ignored process-isolated witness for the original huge input.

The eager allocation limits cannot prove arbitrary variable-width payload bytes or variable nested-child cardinality copied during extend; those remain data-dependent. No public API or dependency changes are included.

Are these changes tested?

Using the supplied shared target and sccache:

  • cargo fmt --check
  • git diff --check
  • cargo test -p datafusion-functions-nested --no-fail-fast (57 passed, 1 ignored; 2 doctests passed)
  • cargo test -p datafusion-functions-nested resize::tests::array_resize_huge_size_returns_controlled_error -- --ignored --exact (passed)
  • cargo clippy -p datafusion-functions-nested --all-targets -- -D warnings
  • cargo check -p datafusion-functions-nested

The pre-fix isolated GreptimeDB witness reproduced the panic 4/4 while its small array_resize([1], 3, 0) control succeeded.

Are there any user-facing changes?

Yes. Oversized array_resize requests now return an execution error containing exceeds the maximum array size instead of panicking. There are no API changes.

Signed-off-by: discord9 <discord9@163.com>
@discord9 discord9 changed the title fix: prevent array_resize capacity overflow panic fix(backport): prevent array_resize capacity overflow panic Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant