Skip to content

GH-54689: [Ruby] Keep TableBatchReader source table alive - #55245

Closed
mikamikasuki wants to merge 1 commit into
apache:mainfrom
mikamikasuki:fix/54689-table-batch-reader-owner
Closed

mikamikasuki wants to merge 1 commit into
apache:mainfrom
mikamikasuki:fix/54689-table-batch-reader-owner

Conversation

@mikamikasuki

@mikamikasuki mikamikasuki commented Oct 25, 2026 •

Copy link
Copy Markdown

Rationale for this change

An exported TableBatchReader can outlive the temporary Ruby Table used to create it. The reader currently holds a reference to the Table, so importing the stream after Ruby garbage collection can segfault.

What changes are included in this PR?

Construct TableBatchReader with its shared_ptr

so it retains the source table for the reader’s lifetime.

Are these changes tested?

Added a Ruby regression that exports a reader from a temporary table, runs GC, imports the stream, and reads all rows. The regression segfaults on current main and passes with this change. The full record-batch-reader test file passes (4 tests, 4 assertions). The Arrow C++ core, GLib bindings, and Ruby extension build succeeded.

Are there any user-facing changes?

This prevents a segmentation fault when an exported TableBatchReader is used after its source Ruby table wrapper is garbage-collected.

This PR contains a "Critical Fix". It prevents a crash when the source table is collected before the exported reader stream is used.

Was AI used for this PR?

OpenAI Codex assisted with root-cause analysis, implementation, and regression-test generation. The contributor reviewed the code and regression output.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Closes #54689

@mikamikasuki
mikamikasuki requested a review from kou as a code owner October 25, 2026 07:52
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54689 has been automatically assigned in GitHub to PR creator.

@kou

kou commented Oct 25, 2026

Copy link
Copy Markdown
Member

We don't need AI only contribution.

@kou kou closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ruby] Exported Arrow::TableBatchReader crashes after GC when its table is not referenced

2 participants