ToniAdreal commented on PR #12437: URL: https://github.com/apache/arrow-rs/pull/12437#issuecomment-7122169854
You're right that after #12410 the checked paths can't produce this anymore — I re-read `main` and confirmed `try_new`/`try_new_with_len` truncate, `From<ArrayData>` slices to `len * value_size`, and `slice()` does the same. The only remaining trigger is `new_unchecked` without `force_validate`, which stores the buffer as-is and whose safety contract requires `values.len() == len * value_length`. So yes, reaching this case does require misusing an `unsafe` API. The reason I still opened it is that #12409 — the issue this PR links to — explicitly called out `append_array` (lines 102–103 in the issue) as a place where trailing bytes "can be appended and corrupt the data of the builder", and asked for stripping "so we have a consistent view of only the bytes involved in the array". #12410 fixed the construction side; this closes the exact spot the issue named. What the guard buys in practice: `append_array` is safe code, and today it trusts `value_data().len()` wholesale, so a trailing-byte array silently corrupts the builder — later elements shift, and `finish()` then builds via `new_unchecked` with a buffer that breaks the `values.len() == len * value_length` guarantee its own SAFETY comment asserts. The fix is a one-line slice to `len * value_size` plus a regression test, so the builder can't propagate the bad state even when handed such an array. If you'd rather treat `new_unchecked` misuse as out of scope for safe-API hardening, I'm happy to close this — no strong attachment. Otherwise it's ready for review. -- 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]
