Skip to content

deps: parser v0.13.0, which bounds nested source instead of crashing on it - #796

Merged
tannevaled merged 1 commit into
mainfrom
deps/parser-v0.13.0
Oct 8, 2026
Merged

tannevaled merged 1 commit into
mainfrom
deps/parser-v0.13.0

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

main was on parser v0.11.1, so rbgo did not have the nesting limit even though it merged upstream two days ago. Deeply nested source still overflowed the Go stack here — a fatal runtime error, not a panic, so recover() cannot contain it and the process dies. run.go calls parser.Parse as its first statement, so a host that merely compiles untrusted Ruby was exposed without ever executing it.

Why it was missed, which is the part worth recording

Parser v0.12.0 existed and looked like the newest release. It was cut before the fix:

$ gh api repos/go-ruby-parser/parser/compare/v0.12.0...main --jq .ahead_by
1
$ … --jq '.commits[].commit.message'
fix: bound expression recursion, so nested source is an error and not a crash (#50)

v0.11.1...v0.12.0 contains one commit — "build: raise the Go floor to 1.27.1" — and nothing else. A higher tag number is not the same as newer code, and the fix sat on the parser's main, one commit past that tag, untagged. Tagged v0.13.0 for this bump.

Measured through rbgo, before and after

x = + f(×N:

depth source this branch main
20 000 60 KB parse error: nesting of 32769 is too deep, exit 1 —
70 000 210 KB same, exit 1 —
100 000 300 KB same, exit 1 fatal error: stack overflow, exit 2

20 000 errors because f( is a 2× production — 20 000 levels is 40 001 frames, past the 32 768 ceiling. That is still well above anything MRI accepts: MRI refuses f(×8000 already, with a Prism SyntaxError. So nothing MRI would have parsed is newly rejected, which is the bound that matters.

Verified

Full suite green (internal/vm 206 s), gofmt -l empty, go vet clean.

Refs go-ruby-parser/parser#48 and #768 — this closes the parser half of that issue for rbgo. The VM half (a frame count cannot bound the Go stack against unbounded native dispatch nesting; ~33 layers reopen it) stays open on #768.

🤖 Generated with Claude Code

…on it

main was on parser v0.11.1, so rbgo did NOT have the nesting limit even though
it merged upstream two days ago. Deeply nested source still overflowed the Go
stack here -- a fatal runtime error, not a panic, so recover() cannot contain it
and the process dies. run.go calls parser.Parse as its FIRST statement, so a
host that merely compiles untrusted Ruby was exposed without executing it.

Worth saying why it was missed: parser v0.12.0 existed and looked like the
newest release, but it was cut BEFORE the fix. `compare v0.11.1...v0.12.0`
contains one commit, "build: raise the Go floor to 1.27.1", and nothing else;
the nesting fix sat on the parser's main, one commit past that tag, untagged.
A higher tag number is not the same as newer code. Tagged v0.13.0 for this.

Measured through rbgo, with `x = ` + `f(`*N:

  depth  20000   60 KB   parse error: nesting of 32769 is too deep   exit 1
  depth  70000  210 KB   parse error: nesting of 32769 is too deep   exit 1
  depth 100000  300 KB   parse error: nesting of 32769 is too deep   exit 1

  main, depth 100000     fatal error: stack overflow                 exit 2

20000 errors because `f(` is a 2x production -- 20000 levels is 40001 frames,
past the 32768 ceiling. That is still well above anything MRI accepts: MRI
refuses `f(`*8000 already, with a Prism SyntaxError. So nothing MRI would have
parsed is newly rejected.

Full suite green (internal/vm 206s), gofmt and vet clean.

Refs go-ruby-parser/parser#48, #768.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 5e7a1b9 into main Oct 8, 2026
9 checks passed
@tannevaled
tannevaled deleted the deps/parser-v0.13.0 branch October 8, 2026 17:30
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