Repository navigation
Conversation
…naligned buffers safely Default and full validation read these through aligned pointers, which is undefined behaviour for the unaligned buffers the C Data interface allows. Follows the fix for offsets buffers in apache#946. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pedrobtz
force-pushed
the
fix-validate-full-unaligned
branch
from
October 22, 2026 15:27
7553e7f to
0f19158
Compare
This branch has not been deployed
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.
#946 fixed
ArrowArrayViewValidate()reading offsets buffers through aligned pointers (#945). Validation still does the same in three other places:ArrowArrayViewGetIntUnsafe(), in default validation (first and last run end) and full validation (the increasing check);data.as_int32[i]anddata.as_int64[i], in full validation;ArrowArrayViewGetIntUnsafe(), in full validation's range check.Each is a misaligned load when the buffer isn't aligned to the element width. That is undefined behaviour, and UBSan reports it, for input the C Data interface allows.
This adds a static
ArrowArrayViewGetIntUnaligned()toarray.c. It reads the 16-, 32- and 64-bit integer types withmemcpyand falls back toArrowArrayViewGetIntUnsafe()for the others. The run-end and dictionary-index sites use it. The list view sites useArrowBufferViewGetInt32Unsafe()andArrowBufferViewGetInt64Unsafe()from #946.The new
ArrayViewTestValidateFullUnalignedIntegerstest validates, at the full level, a dictionary-encoded int32 view with indices at an odd address. It does the same for a run-end-encoded view with odd-addressed run ends, and for list view and large list view with odd-addressed offsets and sizes. Without the fix, UBSan reports the misaligned load (inline_array.h:1160). With it,ctestis clean underUBSAN_OPTIONS=halt_on_error=1.Found by fuzzing the IPC reader in the zuarrow R package, which vendors nanoarrow. A pre-0.15 message whose body buffer starts at an odd offset reached the dictionary index check through
ArrowIpcArrayStreamReader.ArrowArrayAppendStorageFromArrayViewElement()andArrowArrayAppendStorageFromArrayViewRange()read integers, list view sizes and run ends the same way. They are not validation, so they are left for a separate change.ctestpasses in a plain Debug build and with ASan and UBSan withhalt_on_error=1(410 tests each). The changed files are formatted with the pinned clang-format 16.0.6.🤖 Generated with Claude Code