Skip to content

Ownership audit uses a dense 7 GB state matrix for the in-unit regex match body #1173

Closed

Description

@ehartford

The native ownership validator allocates a dense block-by-place matrix and repeatedly copies complete rows, making an unbundled stage1 audit impractical even for a one-line user program.

Repro with a normally bootstrapped stage1 compiler:

fn main: print("ok")

with-stage1 analyze repro.w 'select:kind=body,name=match_' reports the in-unit regex body match_: 39,712 locals and 41,818 blocks. This is also present in the baseline stage1 compiler without the #1172 change. A baseline stage1 analysis of the 14-case temporary-exit fixture produces 644,908 facts; the bundled release compiler produces 15,344.

audit:all on stage1 spends minutes with 7–8 GB resident memory in mir_drop_state_compute_blocks. Native LLDB observes MirDropStateBlocks.load_block -> with_vec_push -> vec_grow -> rt_memcpy. The live row width is 43,194 keys. The exact allocation is mir_drop_state_blocks_new in src/MirCore.w: for _ in 0..bb_count * keys.len(): rows.push(MirDropState.Absent). MirDropStateBlocks.load_block then clones every key of a stored row for input joins and equality checks. The matrix alone exceeds 7 GB for this body.

Expected: full ownership validation remains usable on in-unit dependency bodies, without omitting checks or requiring opaque bundles to hide the large body. This needs a sparse/lazy state representation and/or a proven restriction of tracked places, with the same join and validation semantics. It is separate from #1172's early-return cleanup fix; the completed runtime matrix is clean, and its full audit is being repeated with the normal bundled stage2 compiler.

Evidence under out/with-get-investigation/: audit-stage1-minimal-body.log, return-temps-baseline-stage1-summary.log, return-temps-baseline-large-body.log, and return-temps-audit-progress-lldb.log. The two oversized stage1 audit processes were stopped deliberately; they are not passing evidence.

Activity

  1. ehartford commented on Sep 21, 2026

    @ehartford
    ContributorAuthor

    Reproduced again on 2026-09-21 while investigating #1216. This blocks the documented audit:all preflight even for a five-line formatting repro with no explicit imports.

    Environment and reproduction

    • macOS arm64.
    • Stage1 built at 6eb8ad6f75c74e47f3e63e275857456c5a8b39cc (PR codegen: formatting an Option[&T] no longer crashes the compiler #1216), using the pinned v0.15.2.0 seed and the normal :dev target, at -O1.
    • This observation used the PR compiler before the subsequent nested-reference/Unit formatting fixes, not a compiler built with those fixes.
    • Source saved at the repository root as review_nested_ref.w:
    fn main:
        let v: i32 = 65
        let r: &i32 = &v
        let o: Option[&&i32] = Some(&r)
        print(f"nested={o}")
    
    out/bootstrap/bin/with-stage1 analyze review_nested_ref.w audit:all
    

    Observed

    • At 3 minutes 2 seconds: approximately 99% CPU and RSS 7,486,096 KiB (about 7.1 GiB).
    • At 3 minutes 39 seconds: still running with RSS 7,486,048 KiB.
    • The redirected stdout/stderr log remained empty at those observations: no progress or verdict.
    • Attached LLDB, captured the stack below, detached, and later deliberately terminated the audit. It did not complete, and this is not a passing audit result.
    rt_memset                         rt/rt_core.w:340
    rt_alloc_unlocked                rt/rt_core.w:1317
    rt_alloc_with_origin             rt/rt_core.w:1339
    vec_grow                         rt/rt_core.w:2636
    with_vec_push                    rt/rt_core.w:2670
    MirDropStateBlocks.load_block
    mir_drop_state_compute_blocks
    validate_ownership_body
    validate_ownership_mir_module
    validate_all_mir_module
    analysis_audit_mir
    compiler_analysis_run
    

    This is additional evidence consistent with this issue's dense ownership-state computation. It establishes excessive time/memory use and an apparent hang to the caller, not a proven infinite loop. I did not identify the particular dependency body in this run.

    Expected: the documented small-repro preflight should remain practical without disabling ownership validation. Progress identifying the current body and phase would also make a long-running audit distinguishable from a hang, but would not substitute for fixing the underlying computation.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce as reported: a stage1 audit of a one-line program now finishes in 30 s at 650 MB, not the dense multi-GB matrix.

    $ /usr/bin/time -l out/bootstrap/bin/with-stage1 analyze main.w audit:all   # fn main: print("ok")
    compiler-analysis-audit: facts=939942 violations=1 FAILED
           30.36 real
               649035776  maximum resident set size
    

    Separate finding from the same run: that stage1 audit reports one violation in the in-unit pcre2 corpus: mode-provenance: sizeof/alignof type argument: Sema's type argument and the AST type node disagree in 4 of 466 decisions; first: match_ subject 411326: owner=llvm-kind-8 derived=none.

  3. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25: the separate finding noted above is filed as #2636.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions