Skip to content

Added validation for ContiguousBufferMemory construction#2944

Open
ben-zen wants to merge 5 commits intomicrosoft:mainfrom
ben-zen:validate_ring_buffer
Open

Added validation for ContiguousBufferMemory construction#2944
ben-zen wants to merge 5 commits intomicrosoft:mainfrom
ben-zen:validate_ring_buffer

Conversation

@ben-zen
Copy link

@ben-zen ben-zen commented Mar 11, 2026

ContiguousBufferMemory works by having a rolling len-sized window of valid offsets across all u32 values. The only safe window sizes are therefore powers of 2, otherwise you can potentially have multiple buffers assigned the same offset near the end of the u32 space, due to how modular arithmetic rolls over values.

@ben-zen ben-zen requested a review from a team as a code owner March 11, 2026 17:29
Copilot AI review requested due to automatic review settings March 11, 2026 17:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds input validation to ContiguousBufferManager construction to ensure ring-buffer indexing remains correct across u32 wrap-around, and introduces a unit test to enforce the allowed page_limit values.

Changes:

  • Add a constructor-time validation for page_limit to prevent invalid ring sizing.
  • Add a unit test that checks only power-of-two page counts are accepted.

You can also share your feedback on Copilot code review. Take the survey.

@ben-zen ben-zen force-pushed the validate_ring_buffer branch from a5a0065 to 11ca577 Compare March 11, 2026 18:38
Copilot AI review requested due to automatic review settings March 11, 2026 20:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

@erfrimod erfrimod left a comment

Choose a reason for hiding this comment

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

LGTM

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