Skip to content

NameError: uninitialized constant Node::Item::CaptureRef on ref(N) in from position (parse crash) #864

Closed

Description

@ronaldtse

Summary

A ref(N) item in a from expression crashes the ruby ISC parser with

NameError: uninitialized constant Interscript::Node::Item::CaptureRef

instead of a named parse/semantic error. CaptureRef is referenced but never defined/required on the parse path.

Found by the WO20 differential fuzz campaign (interscript/maps#284): 14 of 1600 cases, all one root cause.

Minimal repro (9 lines)

system "T:fz-em8:1" {
  stage main {
    sequence {
      sub {
        from some(any(["k", "q"])) + ref(1)
        to "W" + ref(1)
      }
    }
  }
}
ruby -Ilib -e '
require "interscript"
Interscript.load_path.unshift(".")
Interscript.parse("map")'
# NameError: uninitialized constant Interscript::Node::Item::CaptureRef

Observed vs expected

runtime behavior on ref(N) in from
ruby (origin/main 4c47eb5) crash NameError: uninitialized constant Interscript::Node::Item::CaptureRef
ts (origin/main b74cfda) parses; named MapLogicError at execution
py (origin/main c6ae457) parses; execution-stage error
rs (release 0.3.2) parses; named logic error at execution

Expected: either a named parse-time rejection ("ref() is not valid in from position") or at minimum the intended MapLogicError — not a NameError constant-lookup crash.

(The runtime-side question — what ref in from SHOULD mean — is tracked cross-runtime in the maps fuzz triage; this issue is only about the accidental crash.)

Activity

  1. added
    crashRuntime crash (uncaught exception / abort) found by fuzzing
    on Nov 16, 2026
  2. ronaldtse commented on Nov 16, 2026

    @ronaldtse
    ContributorAuthor

    Fixed by #866 (branch wo20-fix-ruby off origin/main).

    Red -> green evidence:

    • Pre-fix: the campaign's 9-line repro raises NameError: uninitialized constant Interscript::Node::Item::CaptureRef - reproducible both in-process and in a fresh process.
    • Root cause: the class exists (defined in lib/interscript/node/item/capture.rb, next to CaptureGroup) but node/item.rb had no autoload :CaptureRef entry - the constant only resolved when some earlier dependency parse referenced CaptureGroup first (which loads the file and defines both). The 27 corpus maps with to-position ref() parse today only by that accident; a to-only map crashes the same way (probed during triage).
    • Fix: the missing autoload entry, plus a named parse-time rejection for the invalid flavor: a ref(N) whose capture group the from expression never opens raises Interscript::MapLogicError: ref(1) in from position has no matching capture group - the WO18 G8 fn-literal-in-from convention (a named error, never an accidental exception; with the autoload alone this surface would still die at compile with an accidental RegexpError: invalid backref number/name).
    • Scoping: the pairing gate is count-based because Onigmo accepts any existing group number from any position - so the legal geminate idiom from capture(any_character) + ref(1) (pinned executable by node_adapter_spec, чч -> ч) keeps working, and to-position refs are untouched. Whether unpaired refs should instead be a run-time error like ts/py/rs remains the owner-held cross-runtime question from the triage.
    • Gates: full rake spec 438 examples / 0 failures; standardrb clean on touched files; all 428 corpus maps + 7 libs parse with byte-identical outcomes pre/post (parse-all diff against a pristine 4c47eb5 worktree).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashRuntime crash (uncaught exception / abort) found by fuzzing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions