You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "zanmato1984 (via GitHub)" <gi...@apache.org> on 2026/03/26 22:27:57 UTC
[PR] GH-49392: [C++][Compute] Fix fixed-width gather byte offset overflow in list filtering [arrow]
zanmato1984 opened a new pull request, #49602:
URL: https://github.com/apache/arrow/pull/49602
## Rationale for this change
Issue #49392 reports a user-visible corruption when filtering a table that contains a `list<double>` column: slicing the last row returns the expected values, while filtering the same row returns values from a different child span. The corruption only appears once the selected child-value range is large enough, which points to an overflow in the fixed-width gather path used when list filtering materializes the selected child values.
## What changes are included in this PR?
This patch moves fixed-width gather byte-offset scaling onto an explicit `int64_t` helper before the `memcpy` and `memset` address calculations. That fixes the underlying 32-bit byte-offset overflow when a `uint32` gather index is multiplied by the fixed value width. In the source issue's last-row case, the selected child span starts at `999998000`; for `double` values, scaling that index by 8 bytes wrapped in 32-bit arithmetic and redirected the gather to the wrong child span. Keeping the byte-offset arithmetic in 64 bits makes the fixed-width gather path, the child `Take()` call used under list filtering, and the final filtered `Table` all address the correct bytes.
To validate that this is the same bug reported in the issue, I also used a local near-e2e C++ reproduction that keeps the issue's logical shape (`N=500000`, `ARRAY_LEN=2000`, an `id` column, and a `numbers: list<double>` column), filters the last row, and seeds both the true target child span and the pre-fix wrapped span with distinct sentinels. In that setup, `Slice()` returns the expected row, a replay of the pre-fix gather arithmetic returns the wrapped sentinel span instead, and the fixed child `Take()` and table `Filter()` results both match the sliced row. That ties the user-visible issue and this root-cause fix back to the same overflow boundary.
## Are these changes tested?
Yes. The patch adds a targeted unit test that checks fixed-width gather byte offsets are computed with 64-bit arithmetic. This is intentionally smaller than an end-to-end filter regression: the original user-visible failure only shows up at very large logical offsets, while the new unit test isolates the exact overflow boundary directly without constructing a huge table or depending on a PyArrow-level reproduction. That makes it smaller, more stable, and more appropriate for regular C++ CI, while the near-e2e local reproduction was used separately to confirm that this root-cause regression test and the reported filtering corruption are exercising the same bug.
## Are there any user-facing changes?
Yes. Filtering tables with large list columns backed by fixed-width child values no longer risks returning data from a wrapped byte offset.
* GitHub Issue: #49392
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49392: [C++][Compute] Fix fixed-width gather byte offset overflow in list filtering [arrow]
Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 merged PR #49602:
URL: https://github.com/apache/arrow/pull/49602
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49392: [C++][Compute] Fix fixed-width gather byte offset overflow in list filtering [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49602:
URL: https://github.com/apache/arrow/pull/49602#issuecomment-4138735884
:warning: GitHub issue #49392 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49392: [C++][Compute] Fix fixed-width gather byte offset overflow in list filtering [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #49602:
URL: https://github.com/apache/arrow/pull/49602#issuecomment-4159504160
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 61ef6722b01a289ca6e09d3c5aaef782f060f94c.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/69284680701) has more details. It also includes information about 9 possible false positives for unstable benchmarks that are known to sometimes produce them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49392: [C++][Compute] Fix fixed-width gather byte offset overflow in list filtering [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #49602:
URL: https://github.com/apache/arrow/pull/49602#discussion_r3009896090
##########
cpp/src/arrow/compute/kernels/vector_selection_test.cc:
##########
@@ -104,6 +105,18 @@ void CheckTakeIndicesCase(const std::string& filter_json, const std::string& ind
} // namespace
+// GH-49392: Fixed-width gather byte offsets must be computed in int64_t.
Review Comment:
Is the test actually useful? It's not really doing an end-to-end test, just testing a trivial helper function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49392: [C++][Compute] Fix fixed-width gather byte offset overflow in list filtering [arrow]
Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 commented on code in PR #49602:
URL: https://github.com/apache/arrow/pull/49602#discussion_r3011481217
##########
cpp/src/arrow/compute/kernels/vector_selection_test.cc:
##########
@@ -104,6 +105,18 @@ void CheckTakeIndicesCase(const std::string& filter_json, const std::string& ind
} // namespace
+// GH-49392: Fixed-width gather byte offsets must be computed in int64_t.
Review Comment:
Agreed. This is not particularly useful for a E2E protection. I think I shall remove it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49392: [C++][Compute] Fix fixed-width gather byte offset overflow in list filtering [arrow]
Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 commented on PR #49602:
URL: https://github.com/apache/arrow/pull/49602#issuecomment-4157701058
CI failures seem unrelated. I'm merging this. Thanks @pitrou for reviewing!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org