Repository navigation
Conversation
…cate arrays When ArrowMalloc() failed for the arrays, ArrowBasicArrayStreamInit() called ArrowBasicArrayStreamRelease() on a stream whose private_data had not been stored yet. The release callback then read the caller's unset release and private_data fields, and the schema already moved into the private data leaked. Move the schema back to the caller instead, as the first allocation failure leaves it, and free the private data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paleolimbot
reviewed
Nov 5, 2026
paleolimbot
left a comment
Member
There was a problem hiding this comment.
Thanks!
This is a good catch, although it should probably just not touch the schema in the first place until the allocation has succeeded
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.
When
ArrowMalloc()fails for the arrays,ArrowBasicArrayStreamInit()callsArrowBasicArrayStreamRelease(array_stream)before it has set any ofarray_stream's fields. The release callback then reads the caller's uninitializedreleaseandprivate_data: ifreleasehappens to be non-NULL it dereferences an unsetprivate_data, and if it is NULL nothing is released. Either way the schema, already moved into the private data, leaks.The fix moves the schema back to the caller and frees the private data. That matches the first allocation failure, which returns
ENOMEMbefore taking the schema. The documentation now says that the caller keeps the schema when the function fails.The new
ArrayStreamTestInitErrortest asks forINT64_MAX / sizeof(struct ArrowArray)arrays, so the second allocation fails. It expectsENOMEM, an untouched stream and a schema the caller still owns. Without the fix, the schema'sreleaseis NULL and the test fails. Like the other huge-allocation tests, it is skipped under__SANITIZE_ADDRESS__.This came up while reviewing nanoarrow for the zuarrow R package, which vendors it.
ctestpasses in a plain build and with ASan and UBSan (411 tests; the sanitizer run needsASAN_OPTIONS=allocator_may_return_null=1where the compiler does not define__SANITIZE_ADDRESS__, as for the existing huge-allocation tests). The changed files are formatted with the pinned clang-format 16.0.6.🤖 Generated with Claude Code