Skip to content

Fix quadratic backtracking over malformed strings in check_struct_type - #639

Merged
juntyr merged 2 commits into
ron-rs:masterfrom
danish293:struct-type-lookahead-malformed-string
Oct 24, 2026
Merged

juntyr merged 2 commits into
ron-rs:masterfrom
danish293:struct-type-lookahead-malformed-string

Conversation

@danish293

Copy link
Copy Markdown
Contributor

Quadratic rescan of malformed strings in check_struct_type

The newtype/tuple lookahead only gave up on ExpectedStringEnd/Eof, so a string ending in a bad escape, like A("\"\"\"...\q") deserialised into an untagged enum, was re-parsed from every escaped ". 80 KB of input took 33 s in a release build (16 s for b"...", 7.9 s through #![enable(unwrap_variant_newtypes)], which the document can turn on itself). Now only ExpectedString/ExpectedByteString (not a string here) backtrack, which brings that input to 0.4 ms and reports the actual InvalidEscape.

  • I've included my change in CHANGELOG.md

Comment thread tests/quadratic_struct_type_lookahead.rs Outdated
Comment thread CHANGELOG.md Outdated
@juntyr

juntyr commented Oct 23, 2026

Copy link
Copy Markdown
Member

Thanks @danish293! Once you address my comments, I will merge your PR :)

@juntyr
juntyr merged commit cf16b4d into ron-rs:master Oct 24, 2026
10 checks passed
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