Repository navigation
fix: bound plNested's depth and element count - #15
Merged
Merged
Conversation
plNested took the shape from the first element at each level, so a self-containing Array (a = []; a << a) grew the shape list without end. A shared sub-Array repeated (a = [a, a]) was likewise walked at each place. The depth is now at most 64 levels and the walk at most 2^22 numbers, an ArgumentError past either. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
plNested (plot.go) never terminated on a self-containing Array (
a = []; a << a): the shape list grew without end. A shared sub-Array repeated (a = [a, a]) was also walked at each place.Depth is now bounded at 64 levels and the walk at 2^25 numbers (a 4096x4096 image converts), with an ArgumentError past either (same style as the dfValue bound in #14; Refs #14). The depth bound is the loop condition, so the guard cannot hang if removed.
Tests: cyclic, deep and doubled-shared inputs are refused under a 512 MiB GOMEMLIMIT; the exact edges of both limits are asserted. mutsweep: both changed guards are caught.
Bibliography: https://docs.ruby-lang.org/en/3.4/Array.html (recursive arrays).
🤖 Generated with Claude Code