fix: honor allocation limits at boundary cases - #2
Open
besmpl wants to merge 1 commit into
Open
Conversation
besmpl
marked this pull request as ready for review
August 10, 2026 17:04
besmpl
force-pushed
the
agent/fix-allocation-boundaries
branch
from
August 10, 2026 21:15
b94b8c3 to
1e28061
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
maxAllocscount even when allocations split free regionsuint32Why
The initial free region used one of the advertised allocation nodes. As a result,
New(1024, 1).Allocate(1)attempted to create a remainder through the freelist sentinel and panicked instead of returning the single supported allocation. Fragmented layouts could similarly exhaust structural nodes before reachingmaxAllocs.Free regions are never adjacent after coalescing, so with
Kactive allocations there are at mostK+1free regions. A preallocated2*maxAllocsnode pool (or one initial node for a zero-capacity allocator) therefore covers every reachable layout while the new active count enforces the public limit.Separately,
AllocateAlignedpreviously allowedsize + alignment - 1to wrap, potentially returning a tiny successful allocation for a near-MaxUint32request.Verification
go test ./...go test -race ./...go build ./...go vet ./...golangci-lint run --timeout=5mgo test -covermode=atomic -coverprofile=coverage.out ./...— 99.5% total statement coverage and 100% of changed production statements (42/42; no uncovered changed blocks)0 B/op,0 allocs/opgofmtandgit diff --check