Skip to content

fix: bound plNested's depth and element count - #15

Merged
tannevaled merged 2 commits into
mainfrom
fix/plnested-unbounded
Nov 29, 2026
Merged

tannevaled merged 2 commits into
mainfrom
fix/plnested-unbounded

Conversation

@tannevaled

@tannevaled tannevaled commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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

tannevaled and others added 2 commits November 29, 2026 20:11
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>
@tannevaled
tannevaled merged commit b6fab03 into main Nov 29, 2026
60 checks passed
@tannevaled
tannevaled deleted the fix/plnested-unbounded branch November 29, 2026 20:21
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.

1 participant