Repository navigation
Conversation
rok
force-pushed
the
cpp-ipc-validate-sparse-tensor-indices
branch
from
November 2, 2026 18:43
473cec3 to
83eba91
Compare
Member
Author
|
@pitrou here's a proposal for several sparse index checkers. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Sparse tensor validation can read past the buffer because the index and indptr helpers assume packed storage without rejecting non-contiguous vectors.
1 open issue
What changed in this PR
This PR strengthens C++ sparse tensor validation for GH-50816, rejecting malformed indices before dense conversion and correcting CSF index buffer sizing in IPC.
Changes:
- Validate index bounds, buffers, compressed pointers, axis ordering, and conversion sizes.
- Respect COO coordinate strides and encode CSF IPC buffer lengths in bytes.
- Add regression tests for malformed inputs and IPC round trips.
| File | Description |
|---|---|
| cpp/src/arrow/tensor/coo_converter.cc | Respect coordinate strides during dense conversion. |
| cpp/src/arrow/tensor.h | Declare the shared permutation validator. |
| cpp/src/arrow/tensor.cc | Implement the shared permutation validator. |
| cpp/src/arrow/tensor_test.cc | Test valid and invalid permutations. |
| cpp/src/arrow/sparse_tensor.h | Declare and connect sparse index validation. |
| cpp/src/arrow/sparse_tensor.cc | Validate sparse indices, buffers, and conversion sizes. |
| cpp/src/arrow/sparse_tensor_test.cc | Add sparse validation and conversion regressions. |
| cpp/src/arrow/ipc/tensor_test.cc | Test CSF buffer sizing and invalid IPC inputs. |
| cpp/src/arrow/ipc/metadata_internal.cc | Correct CSF buffer lengths and validate layouts. |
| cpp/src/arrow/extension/tensor_internal.h | Remove the relocated validator declaration. |
| cpp/src/arrow/extension/tensor_internal.cc | Remove the relocated validator implementation. |
Review effort: Balanced
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer review is needed to clarify compatibility expectations for previously serialized CSF messages and older readers when IPC buffer lengths change from element counts to byte counts.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Rationale for this change
Invalid sparse tensor indices should be rejected consistently before sparse-to-dense conversion.
What changes are included in this PR?
Are these changes tested?
Regression tests were added for invalid CSF axis ordering and out-of-range CSR and CSF indices. C++ formatting and lint checks pass.
Are there any user-facing changes?
Invalid sparse tensor inputs that were previously accepted are now rejected with an
Invalidstatus.