Skip to content

Type-checker root-cause investigation: reproduce the 16–32 GiB allocation observed on Windows in #1 #14

@hyperpolymath

Description

@hyperpolymath

Follow-up to #1 / #12.

PR #12 added MAX_EXPR_DEPTH = 256 in crates/my-lang/src/checker.rs so that pathological inputs now produce a clean ExpressionTooDeep diagnostic instead of OOM-aborting. That fixes the symptom.

The root cause is still unknown:

  • The checker's check_expr and is_assignable_from are structurally linear in AST size on the inputs I tested on Linux.
  • I could not reproduce a 16–32 GiB allocation locally on Linux even with the issue's exact str_concat / format shape, depth, and function count.
  • The original report is stable-x86_64-pc-windows-msvc, rustc 1.95.0 on Windows 11 Pro for Workstations 26300, against a ~330 LOC scaffold tool.

What this issue tracks

  1. Obtain a copy of the actual ~330 LOC repro that triggered the OOM (the issue describes the shape but the file itself was not attached).
  2. Reproduce on Windows with the same toolchain, ideally with heaptrack / dhat / Windows ETW + -Z time-passes to localise the allocator hotspot.
  3. Confirm whether the cause is in the checker, in HIR/MIR lowering (only on my run), or elsewhere (e.g. a Windows allocator interaction or a debug-info / span-table blow-up). The issue title says "type-checker" but my check is only parse + check, so it's confirmed pre-lowering.
  4. If a real superlinear hotspot exists, replace the depth guard's role-of-last-resort with a targeted fix (memoisation of str_concat/format subexpressions, or a structural rewrite).

Why this matters

The depth guard prevents OOM but at the cost of rejecting deep-but-otherwise-legal programs at 256 nesting levels. If the real cost is exponential in the number of templating sites (as the original report suggests with "aggregate complexity of nested string-building constructs"), then files well under the depth limit could still hit it. We need to know.

Out of scope

  • Parser-side depth guard (tracked separately).
  • Memoisation refactor as a speculative fix without first having a real measurement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions