vladosskins178 opened a new pull request, #55746: URL: https://github.com/apache/arrow/pull/55746
### Rationale for this change `year_month_day` reserves one element in each of its three `Int64Builder` children, then appends every row with `UnsafeAppend`. The builders round the reservation up to 32 elements, so for inputs longer than 32 rows the kernel writes past the child buffers. The result has zeros or garbage from row 32 on, the first rows of `month`/`day` can be overwritten, and the heap is corrupted (see #55743 for the valgrind output). ### What changes are included in this PR? Reserve `in.length` elements in each child builder, as `ISOCalendar::Exec` already does for the same struct layout. ### Are these changes tested? Yes. A new test, `ScalarTemporalTest.YearMonthDayLongInput`, runs `year_month_day` on 100 rows (with and without nulls) for `date32`, `date64`, `timestamp[s]` and `timestamp[ns, UTC]`, and compares the result with `year`, `month` and `day`. Without the fix the test binary crashes with a segfault in this test (Debug build, GCC 13, Linux x86_64). With the fix it passes, and the full `arrow-compute-scalar-temporal-test` passes too (56 tests, also with `--gtest_repeat=3`). ### Are there any user-facing changes? Yes: `year_month_day` returns correct results for arrays longer than 32 rows. **This PR contains a "Critical Fix".** Before this change, `year_month_day` produced incorrect data and wrote past the end of heap buffers (memory corruption, possible crash) for any input longer than 32 rows. ### Was AI used for this PR? **PR code and description written by:** - [ ] Human - [x] AI **Reviewed before submission by:** - [ ] Human - [x] AI - [ ] Not reviewed The change and the test were written with an AI coding assistant (Claude Code). I checked the bug in pyarrow 26.0.1, ran the new test before and after the fix, and ran the full temporal test binary. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
