Skip to content

Avoid overflowing the final value in range iteration - #909

Open
vinsymoyya wants to merge 2 commits into
google:masterfrom
vinsymoyya:fix/range-int32-bound
Open

vinsymoyya wants to merge 2 commits into
google:masterfrom
vinsymoyya:fix/range-int32-bound

Conversation

@vinsymoyya

@vinsymoyya vinsymoyya commented Nov 12, 2026 •

Copy link
Copy Markdown

Fixes #906.

Iterate over the allocated output indexes instead of incrementing the range value past the endpoint. On 386, std.range(2147483647, 2147483647) previously overflowed its loop variable after producing the final element, then crashed with an out-of-bounds array write. The two-element range ending at the same value had the same failure.

Both boundary cases reproduce internal errors against the original production code in a native Windows/386 binary. Regression tests in range_endpoint_test.go, registered in the Bazel test target, now verify the exact singleton/pair output as well as ordinary ascending and empty ranges.

Validation:

  • Go 1.27.4 Windows/386: GOARCH=386 go test . -run TestRangeMaximumInt32Endpoint -count=1 passes.
  • Go 1.24.13 Linux/amd64, from an immutable archive of this commit: go test -buildvcs=false ./... passes.
  • gofmt and git diff --check pass.

The native Windows broad run encounters pre-existing golden-path separator mismatches (testdata\ versus testdata/); the full Go suite passes in Linux. Bazel and the C/Python-binding integration suite have not been run locally.

This branch has not been deployed

No deployments
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.

std.range crashes at the maximum int32 endpoint on 386

1 participant