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
fix(serialization): enforce Arc buffer bounds and lifetimes - #11474
Arc buffers need consistent bounds, page ownership, and borrowed-reader behavior across empty values, slicing, disposal, and reader forks. This extracts the buffer and reader correctness prerequisite from #11463, using source 9dd1a83414593ebea731a9abbb2fe44c6851c1d6 on main pin b3b76e2ab207f00e664e0167cd733800cd60379d.
The public ArcBuffer constructor validates page tokens, offsets, lengths, and linked-page coverage before creating a borrowed view. Writer and slice operations use their established bounds for internal construction. Default and Empty buffers are valid owner-free values, with explicitly nullable first-page metadata. Page-backed empty slices acquire independent pins, slices keep offsets within their referenced page, and disposed buffers are checked at reader and enumeration boundaries. Disposed writers reject mutation and can be reset.
Arc reader input skips consecutive empty pages, supports owner-free empty input, and keeps nested forks aligned with global stream offsets. XML documentation states the borrowed input lifetime. Independent lifetime tests cover constructor bounds and pin counts, nullable API metadata, final page release, retained bytes, disposal, consecutive empty pages, and raw-byte nested forks. The generated Serialization API surface accompanies the implementation.
The codec/copier and owned reader API remain in #11463, which will build on this prerequisite. Existing page-pool behavior is preserved.
The newest successful coverage run tested d558f4c, not current main 4268237.
Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.
The comparison remains report-only while normal line and branch variance is calibrated.
AppendPinned still bypasses the new disposal guard for empty input because it returns before calling ThrowIfPinnedPages. As a result, writer.Dispose(); writer.AppendPinned(ArcBuffer.Empty) succeeds even though the other zero-length mutation paths now consistently throw. Check disposal before the empty-input early return.
Addressed the review-summary feedback "AppendPinned bypasses disposal guard for empty input" in 37bbb3a. The empty-input path now calls the disposal-only guard before returning, so disposed writers throw ObjectDisposedException for both owner-free and page-backed empty input. Live empty appends remain a no-op, including writers containing pinned pages, with unchanged reference counts. Regression tests also verify retained bytes and reuse after Reset. All 123 selected Arc buffer/lifetime/reader tests pass on both .NET 8 and .NET 10; normal Release Serialization package validation passes.
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
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.
Arc buffers need consistent bounds, page ownership, and borrowed-reader behavior across empty values, slicing, disposal, and reader forks. This extracts the buffer and reader correctness prerequisite from #11463, using source
9dd1a83414593ebea731a9abbb2fe44c6851c1d6on main pinb3b76e2ab207f00e664e0167cd733800cd60379d.The public
ArcBufferconstructor validates page tokens, offsets, lengths, and linked-page coverage before creating a borrowed view. Writer and slice operations use their established bounds for internal construction. Default andEmptybuffers are valid owner-free values, with explicitly nullable first-page metadata. Page-backed empty slices acquire independent pins, slices keep offsets within their referenced page, and disposed buffers are checked at reader and enumeration boundaries. Disposed writers reject mutation and can be reset.Arc reader input skips consecutive empty pages, supports owner-free empty input, and keeps nested forks aligned with global stream offsets. XML documentation states the borrowed input lifetime. Independent lifetime tests cover constructor bounds and pin counts, nullable API metadata, final page release, retained bytes, disposal, consecutive empty pages, and raw-byte nested forks. The generated Serialization API surface accompanies the implementation.
The codec/copier and owned reader API remain in #11463, which will build on this prerequisite. Existing page-pool behavior is preserved.
Microsoft Reviewers: Open in CodeFlow