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(vector): refuse insert and resize_set past the element limit - #3769
After the Reserve overflow fix a vector can reach count INT_MAX through ResizeSet, and Insert then overflowed count + 1, skipped growing and wrote past the allocation.
Insert and ResizeSet now panic with a clear message at the limit, like Push. The other count + n sites in the file already go through these paths.
Test: tests/en/stdlib/vector_count_limit (ResizeSet to the limit, then Insert panics).
Summary by CodeRabbit
Bug Fixes
Vector resizing and insertion now stop with an error when an operation would exceed the supported element-count limit, before changing the vector.
Vector.resize_set and Vector.insert now panic when their specified count-limit conditions apply. A regression test checks insertion after resizing to length 2147483646.
Changes: Vector count limit
Layer / File(s)
Summary
Count-limit checks and regression test std/collections/vector.salam, tests/en/stdlib/vector_count_limit.salam, tests/en/stdlib/vector_count_limit.exit
resize_set and non-append insert now panic at the specified limits. The test resizes a vector to 2147483646, inserts at index 0, and expects exit code 134.
SalamLang/Salam#3765: Updates vector capacity growth and push behavior at INT_MAX, which is directly related to the element-limit checks in this change.
Suggested labels:tests
Suggested reviewers:bdadmehr0, erfangnu
Merge Risk: Moderate · up to c87d1
The new regression test for the vector count limit is likely to fail in the test runner because its expected output includes a stderr panic line, and it may also fail on Windows because of the abort exit status. The library change looks sound, but fix the test expectations before merging.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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.
After the Reserve overflow fix a vector can reach count INT_MAX through ResizeSet, and Insert then overflowed count + 1, skipped growing and wrote past the allocation.
Insert and ResizeSet now panic with a clear message at the limit, like Push. The other count + n sites in the file already go through these paths.
Test: tests/en/stdlib/vector_count_limit (ResizeSet to the limit, then Insert panics).
Summary by CodeRabbit