Skip to content

codegen: intermittent wrong sum in heavy mixed Array+TypedArray+WeakMap loop (non-GC, post-#6132) #6136

Description

@proggeramlug

Summary

After #6132 was fixed, a smaller, intermittent wrong-answer remains in a heavy mixed loop that reads an object's plain-Array field (for-of) and typed-array field (for-i) plus a WeakMap lookup, every tick, over ~100 retained nodes. It is non-GC — it reproduces with the moving GC disabled (PERRY_GC_MOVING_SAFEPOINT=0), so it is unrelated to relocation. It was masked before by the #6132 crash.

Symptom

The final checksum alternates between two close values across runs — e.g. 275722386 and 276061186 — where 276061186 matches Node. So Perry intermittently computes a slightly-low sum (~339k short). Deterministic programs must not vary run-to-run.

Repro: scratchpad/vB.ts (object { id, payload:number[], buf:Uint32Array }, retained + pruned to ~100, per-tick sum of payload + buf + wm.get(node); async ticks). Reproduces with the flag off.

Notes / suspicion

  • The minimal single-object codegen: typed-array element loop reads wrong sum when object has a sibling Array field #6132 matrix is fully deterministic and correct, so the typed-feedback boxed fallback is correct in isolation — the divergence needs the heavier retained/per-tick/WeakMap combination.
  • Two close alternating values suggests one contribution (one node's wm.get, or one element of one array) is occasionally dropped/misread. Next step: bisect vB by removing the WeakMap term, then the payload term, to localize which read intermittently differs; then --trace llvm the surviving loop.

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