Skip to content

Pool/ID-integrity: adding one declaration corrupts parsing or name resolution of later-parsed modules (issue61-regression canary, red since <=10f7771e) #660

Closed

Description

@ehartford

What the canary caught

issue61-regression (build.w:583) copies the repo, inserts one padding local into SemaCheck.w, and re-checks. It currently fails — and was verified to fail identically at the handoff baseline 10f7771e (git worktree + same patch + baseline binary), so this predates the current campaign. Every earlier :test run died at an earlier target, masking it.

Two repro variants (both deterministic, both ~90s check src/main.w)

Scratch repo recipe: copy src/ + lib symlink + out/gen/compiler/EmbeddedStdlibData.w + EmbeddedClangResourceData.w, then:

  1. Statement in SemaCheck.w (the canary's own patch: one var local after the marker comment at the 'Check all arguments' line): check src/main.w fails with expected declaration (fn, type, enum, let, use, extern) at main.w:4465:1 — one line past EOF (main.w has 4464 lines; root module parses last).
  2. Top-level let ISSUE61_PROBE_PAD: i32 = 0 appended to Sema.w: fails instead with a cascade of undefined variable errors for every local binding inside one specific CodegenTraits.w function (comp_verify_trait_tables — trait_idx reported undefined one line below its own for binding).

Discriminating facts established

  • Comment-only padding (bytes, no tokens/nodes) passes → the threshold is a token/node/extra COUNT, not a byte/offset budget.
  • Both the current binary and the baseline 10f7771e binary fail identically on the same patched tree → tree-content-dependent, not a compiler regression.
  • Both manifestations hit late-parsed material (root-module EOF; a late module's function) → consistent with corruption at the pool tail once a global count crosses a limit.
  • analyze audit:storage (the #storage guard for the historic 32767/65535 node-id overflow in Sema tables) passes — this lives in an unguarded tier (parser pool / extra table / binding-scope keys).
  • fn_meta is flat i32 storage (no packing); FN_META_REQUIRED_UNIT=65536 flag packing reviewed and not obviously implicated.

Why it matters

The whole point of the canary: any real edit that grows the tree by one declaration can silently corrupt parsing/resolution of unrelated modules. The current tree sits within a few nodes of the limit — the next legitimate compiler change could trip it in normal development.

Suggested attack

lldb on repro 2 (fails fast, rich state): break at SemaCheck.w:6287 (undefined variable emission), inspect the ident node id, symbol id, and the binding-scope table keys for the enclosing function; compare against the unpatched run. Then instrument the pool sizes (nodes / extra / symbols) at end-of-parse in both runs and diff against powers of two. Fix at the producing table; extend audit:storage to permanently guard this tier like the sema tables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions