Skip to content

fix: bound JSON nesting depth to prevent stack overflow (#540) - #546

Merged
LunaStev merged 3 commits into
wavefnd:masterfrom
slsgzs-cloud:fix-json-depth-limit
Sep 10, 2026
Merged

LunaStev merged 3 commits into
wavefnd:masterfrom
slsgzs-cloud:fix-json-depth-limit

Conversation

@slsgzs-cloud

@slsgzs-cloud slsgzs-cloud commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two fixes in this PR:

Fix 1: Bound JSON nesting depth to prevent stack overflow (#540)

parse_value recursively calls parse_array/parse_object without tracking a depth limit. Nested metadata can consume call stack proportional to input nesting.

  • Add MAX_DEPTH = 256 constant and depth: usize field to Parser
  • Check depth >= MAX_DEPTH at the start of parse_array and parse_object
  • Return Err("maximum nesting depth exceeded") when limit reached

Fix 2: Stop classifying valid program stderr as compiler failure (#538)

run_and_classify checked looks_like_fail(result.stderr) before comparing the expected exit status. Any stderr containing phrases such as stack overflow, SyntaxError, or error[E was rejected, even when the program deliberately printed that text and exited with the expected status.

Fix: check exit code first. If the program exits with the expected status, it succeeded — don't reject based on stderr content alone. The compiler/child output is combined, so a real compiler failure would show as a non-zero exit code, not just stderr text.

@LunaStev
LunaStev requested review from LunaStev and ehcl2048 and removed request for LunaStev and ehcl2048 September 8, 2026 15:18
@LunaStev

Copy link
Copy Markdown
Member

LGTM

@LunaStev
LunaStev merged commit ea74c2d into wavefnd:master Sep 10, 2026
3 of 26 checks passed
@LunaStev LunaStev mentioned this pull request Sep 30, 2026
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.

2 participants