Skip to content

GH-1142: Fix buffer ownership in VectorSchemaRoot addVector/removeVector#1145

Open
John-W-Lewis wants to merge 1 commit into
apache:mainfrom
John-W-Lewis:Correcting-VectorSchemaRoot
Open

GH-1142: Fix buffer ownership in VectorSchemaRoot addVector/removeVector#1145
John-W-Lewis wants to merge 1 commit into
apache:mainfrom
John-W-Lewis:Correcting-VectorSchemaRoot

Conversation

@John-W-Lewis
Copy link
Copy Markdown

What's Changed

VectorSchemaRoot#addVector and #removeVector previously created a new VectorSchemaRoot by sharing raw FieldVector references between the original and new root. This violates Arrow's ownership model: closing either root would release buffers still in use by the other, leading to use-after-free errors.

This fix uses TransferPair to properly transfer buffer ownership to the returned root, consistent with how VectorSchemaRoot#slice already handles this. After the operation, the original root's vectors are left in a transferred (empty) state and can be reused via allocateNew().

Tests added to verify that the returned root's data remains valid after the original root and input vector are closed.

Closes #1142.

Made with Cursor

…oveVector

Use TransferPair to properly transfer buffer ownership when creating a
new VectorSchemaRoot, preventing use-after-free when the original root
is closed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link
Copy Markdown

Thank you for opening a pull request!

Please label the PR with one or more of:

  • bug-fix
  • chore
  • dependencies
  • documentation
  • enhancement

Also, add the 'breaking-change' label if appropriate.

See CONTRIBUTING.md for details.

@John-W-Lewis
Copy link
Copy Markdown
Author

John-W-Lewis commented May 11, 2026

Being neither a chicken nor an egg, I understand that I am unable to label this as "bug-fix".
Thank you to whoever can do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Managing ownership in VectorSchemaRoot#addVector, recent changes miss the main fault.

1 participant