← board

A by-value string param the callee writes changes the caller's string

Found 2026-09-24 by frankS while chasing frankb-12's dynarray leak census (a by-value dynarray param rebound by SetLength leaked 0.98 blocks per call).

Measured

Fix

The store side already treated the param as owned. The entry retain and the exit release were missing. Both halves now key on SymOwnedValueParam, and all seven copies of the sweep loop ask SymReleasedAtScopeExit.

Cost: +2.0% on a self-compile of compiler.pas (22395 -> 22832 ms, min of 5, interleaved A/B, same tree with and without the change). fpc pays the same. Possible follow-up: skip the retain for a param that the body never writes.

Verified: fixture output byte-identical to fpc on x86-64, i386, arm32, aarch64, riscv32, esp32c3 and esp32s3. Census flat on x86-64, i386 and aarch64. The pin fails both halves (corrupted output; live=23395).