You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 609fdbd
Browse filesBrowse the repository at this point in the historyBrowse files
The follow-up Codex flagged on #73. `using IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(n);
return owner.Memory;` is sugar for `try { return owner.Memory; } finally { owner.Dispose(); }` — the
implicit scope-exit dispose hands the caller a Memory backed by a buffer already returned to the pool:
a dangling borrow. Previously silent because the flow-locals candidate pass skips `using` locals
(auto-disposed, non-leak), so the owner never entered `tracked`.
Fix (extractor only, reuses #70's onReturn / ReturnedViewOwners machinery): a new LowerFlowStatements
desugars a TRACKED `using IMemoryOwner = MemoryPool.Rent(...)` declaration into
`acquire; try { rest } finally { release }` — the using-dispose is threaded onto the rest's
returns/throws, so a returned view of the owner is read after the release -> OWN002. Routed from
LowerFlowBody, the BlockSyntax case, and the try-body. With no such `using` declaration,
LowerFlowStatements lowers each statement exactly as the old loop, so every existing shape (incl. #73's
`using owner; Consume(owner.Memory.Span)` after.cs) is unchanged. The candidate pass now tracks `using`
MemoryPool owners (gated to IsMemoryPoolRent).
Corpus: memorypool-using-view-escape (before: `using owner; return owner.Memory` -> OWN002; after:
return the IMemoryOwner, ownership transferred -> silent) — the MemoryPool twin of
arraypool-memory-view-escape (#70). Benchmark recall floor 17 -> 18. P-007 status updated.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgED
0 commit comments