Skip to content

Prevent use-after free if memory pool is disposed - #738

Merged
adamreeve merged 1 commit into
G-Research:masterfrom
adamreeve:proxy-mem-pool-crash-after-dispose
Nov 4, 2026
Merged

adamreeve merged 1 commit into
G-Research:masterfrom
adamreeve:proxy-mem-pool-crash-after-dispose

Conversation

@adamreeve

@adamreeve adamreeve commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Follow up to #736

Add references to the ProxyMemoryPool handle to keep it alive even if disposed, as long as it's still used by a ParquetFileWriter.

Add references to the ProxyMemoryPool handle to keep it alive
even if disposed, as long as it's still used by a ParquetFileWriter.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the proxy memory pool lifetime changes.

No open issues 🎉

What changed in this PR

This follow-up to #736 protects native proxy memory pools from premature release when disposed while still used by Parquet objects.

Changes:

  • Add native-handle leases so dependent objects keep proxy pools alive until freed.
  • Track explicit disposal separately to reject new direct uses of a disposed pool.
  • Add regression tests for disposing pools while writers, builders, and readers remain in use.
File Description
csharp/​WriterPropertiesBuilder.cs Acquire and release pool leases as the builder’s pool changes or the builder is freed.
csharp/​ProxyMemoryPool.cs Implement handle leases, track disposal, and clarify lifetime guarantees.
csharp/​MemoryPool.cs Add lease hooks and use them in native-object cleanup callbacks.
csharp.test/​TestProxyMemoryPool.cs Test continued writer, builder, and reader use after pool disposal.

Review effort: Balanced

@adamreeve
adamreeve marked this pull request as ready for review November 4, 2026 09:07
@adamreeve
adamreeve merged commit 91c2eb8 into G-Research:master Nov 4, 2026
53 checks passed
@adamreeve
adamreeve deleted the proxy-mem-pool-crash-after-dispose branch November 4, 2026 19:49
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.

3 participants