Skip to content

fix(isc): terminate truncated maps; name malformed escape errors (WO20 fuzz #43, #44) - #45

Merged
ronaldtse merged 1 commit into
mainfrom
wo20-fix-py
Nov 16, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
wo20-fix-py

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

Fixes the two py crash classes found by the WO20 differential fuzz campaign (triage: interscript/maps#284, scripts/fuzz/TRIAGE.md):

  • ISC parser hangs forever on truncated maps (unterminated sub/stage block spins in _stage) #43 (hang): the two _stage block loops broke only on }, so a map truncated before a closing brace spun forever in the skip-line fallback (_stage <- _block_items <- parse, 100% CPU). Added the standard EOF progress invariant - the same self._pos >= len(self._src) guard _block_items already has - to the stage loop and the sequence/parallel rule loop; the trailing _expect("}") then names the failure with a line:col pointer.

  • Malformed \u escapes raise raw ValueError instead of IscParseError (107 fuzz cases) #44 (107 cases - the campaign's largest crash class): malformed \u escapes raised a raw ValueError: invalid literal for int() with base 16: ... instead of IscParseError - including from metadata note text, which shares the string scanner. Decoding now routes through _unicode_escape: exactly 4 hex digits (the grammar's esc_uni4), otherwise IscParseError with line:col at the escape's backslash. The capital \U form stays literal-U - the deviation ts documents in actions.ts (ruby's artifact parser decodes both spellings; aligning the runtimes is an owner decision, not this fix's to make).

Error-path only - no accept-language changes

  • Valid \uXXXX decodes byte-identically (control test passes pre- and post-fix).
  • \U handling untouched (pinned by a new test to the ts-parity literal passthrough).
  • Ruby-parity on the matrix: \u{...} / \uZZZZ / \u00E now reject named, exactly like ruby/ts/rs.

Tests

  • Per repro shape: the campaign's 10-line hang repro and the 90-byte escape repro, plus the inner-loop hang shape.
  • Malformed-escape matrix: short hex, non-hex head/tail, braced form, end-of-string and end-of-file cuts, note-text placement; position-pointer assertions.
  • Class closure: a deterministic sweep parsing every truncation of two real corpus maps (var-ara-Arab-Arab-rababa, royin-tha-Thai-Latn-1999 - committed verbatim): each prefix must yield a document or a named IscParseError, never a spin or an accidental exception (2,414 prefixes, sub-second).

Gates

  • Full py suite green: 99 passed, 1 xpassed (92 passed pre-fix baseline + 7 new tests; the 3 hang tests hung under a 25 s alarm pre-fix, 2 escape tests failed with the raw ValueError).
  • Both issue repros now terminate named:
    • hang.isc -> IscParseError: hang.isc: line 10:4: Expected '}' but got ''
    • escape.isc -> IscParseError: escape.isc: line 4:12: Invalid \u escape: expected exactly 4 hexadecimal digits
  • Fuzz smoke corpus (199 cases, four runtimes) stays green: findings 0 before and after; 7 smoke cases flipped known -> agree (all seven were py ValueError-crash cases now agreeing on IscParseError) - smoke corpus untouched.
  • Ruby-repo py subtree (unchanged by this PR) re-verified green: 450 passed / 8 skipped against the 13,745-row rs-golden; py-vs-py parity driver --hand-rev 7a84260 holds at canonical 432/435, raw 432/435.

Fixes #43
Fixes #44

Two WO20 differential fuzz fixes (campaign: interscript/maps#284):

- interscript-py#43 (hang): the two _stage block loops broke only on
  `}`, so a map truncated before the closing brace span forever in
  the skip-line fallback. Add the standard EOF progress invariant
  (the _block_items guard); the trailing _expect("}") names the
  failure with line:col. The new sweep test parses every truncation
  of two verbatim corpus maps and requires a document or a named
  IscParseError - never a spin, never an accidental exception.
- interscript-py#44 (the campaign's largest crash class, 107 cases):
  malformed \u escapes leaked a raw ValueError from int(), including
  from metadata note text, which shares this scanner. Decoding now
  routes through _unicode_escape and raises IscParseError with
  line:col at the escape. The capital \U form stays literal-U (the
  ts hand-parser parity deviation; decoding both spellings is the
  owner-held cross-runtime alignment).
@ronaldtse
ronaldtse merged commit fb1419c into main Nov 16, 2026
8 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

1 participant