Skip to content

fix: resolve stack overflow on deeply nested arrays (#381)#388

Open
gildor wants to merge 1 commit into
orchestr7:mainfrom
gildor:fix/stackoverflow-nested-381
Open

fix: resolve stack overflow on deeply nested arrays (#381)#388
gildor wants to merge 1 commit into
orchestr7:mainfrom
gildor:fix/stackoverflow-nested-381

Conversation

@gildor

@gildor gildor commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #381 (the stack overflow).

Deeply nested arrays could overflow the stack because multiline-array end detection used a "does the joined string end with ]]" check. This rewrites it to bracket-balance counting that ignores brackets inside quoted strings.

  • TomlArray: trim leading whitespace before bracket removal
  • TomlMultilineString: hasClosedMultilineArray() - balance [/] outside quotes to decide when a multiline array is closed
  • Issue381Test: regression coverage (nested arrays + inline-comment edge cases)

Compliance suite: valid/array/nested-double.toml now passes and is removed from the baseline. valid/comment/tricky.toml no longer overflows either, but it still fails on unrelated value/comment handling (floats-with-comments like 10e2#1, etc.), so it stays baselined under #381 for a separate follow-up rather than being falsely marked as passing.

@gildor
gildor marked this pull request as ready for review July 2, 2026 05:10
Rewrite hasClosedMultilineArray() to use bracket-balance counting instead of naive end-detection, fixing deeply nested arrays and tricky comments.

- TomlMultilineString: bracket-balance end detection
- TomlArray: trim leading whitespace before bracket removal
- Add regression tests (Issue381Test)
- Remove StackOverflowOnNesting from baseline

(cherry picked from commit b9f3644)
@gildor
gildor force-pushed the fix/stackoverflow-nested-381 branch from 37a471e to 654d941 Compare July 2, 2026 05:27
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.

Stack overflow on deeply nested structures

1 participant