Repository navigation
fix: Set an exported array's release callback only once the export has succeeded (#547) - #549
Merged
CurtHagenlocher merged 1 commit intoDec 5, 2026
Conversation
…s succeeded (apache#547) ### What's changed? `CArrowArrayExporter` set each struct's `release` callback and private data as soon as it started converting it. If the export then failed, for example because one of the array's buffers had already been disposed, the exporter freed the memory it had allocated but left the caller's struct with `release` set and pointing at that memory. Releasing the struct afterwards, as `CArrowArray.Free` does, then read freed memory. Each failure also kept a GC handle to the exporter's allocations. - The array or record batch is converted in full first. Only then are the release callbacks and private data set, children first. - If the export fails, the caller's struct is left zeroed, which marks it as released, and the exception is rethrown. This covers `ExportArray`, `ExportRecordBatch`, and the stream and device exporters that use them. The schema exporter already sets `release` last, so it is unchanged. ### Testing New tests in `CDataInterfaceDataTests` export a struct array with a disposed child and a record batch with a disposed column (with and without ownership transfer), check that the struct is left released, and free it. Without the change they fail, and on net472 freeing the struct crashed the test host. All of `Apache.Arrow.Tests`, including the pyarrow C Data tests, passes on net8.0, net462 and net472. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012dFdcrBz22tRjiyNwBd7VB --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> The record batch test calls ExportRecordBatch(batch, cArray), as there is no transferOwnership overload here. (cherry picked from commit 38ce7ee) Claude-Session: https://claude.ai/code/session_012dFdcrBz22tRjiyNwBd7VB
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.
Brings #547 to maint-23.x. maint-23.x has no transferOwnership overload of ExportRecordBatch, so the record batch test calls the two-argument overload.