You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A str field read as a function's tail from an owned local is copied without a retain: let v = make(); …; v.text returns a freed str (double free) #3080
while the same read written return value.text lowers to _0 = copy+retain _2.text. materialize_tail_read_of_dropped_local (MirLower.w) reads a projected copy into a temp before the scope's drops so the read does not follow the drop (#1991), but the copy into that temp carries no hold, so a counted type (a str, a CoW List) gains a holder without a retain: the owner's drop frees the buffer and the function returns it.
Found by the src/ ceremony sweep (#3061): .clone() on a str is ceremony under D111, and the 178 removals exposed this at ComptimeEval.capability_arg_str and its siblings (let value = self.extra_value_at(…); …; value.text), which then corrupted a build.w generated-source path (cli-selfhost-build-w-tests, build-w-generated-source). The clones had been hiding the bug.
Fix: the temp read retains as any owning destination does (retain_consumed_copy on the copy operand). Fixture: test/debug_alloc/da_<this>_tail_field_read_retains.w.
Fixed on branch fix-ceremony-5 (PR #3079): materialize_tail_read_of_dropped_local now calls retain_consumed_copy on the temp's read, so the tail lowers to _5 = copy+retain _2.text; drop(_2); _0 = copy+take _5. The repro, the fixture da_3080_tail_field_read_retains, and the build.w generated-source case all run clean under the debug allocator; the repro's output also changes from the wrong p2.w p2.w to p1.w p2.w.
Activity
#3080: a str field read as a function's tail from an owned local retains
ehartford commentedon Nov 8, 2026
Fixed on branch
fix-ceremony-5(PR #3079):materialize_tail_read_of_dropped_localnow callsretain_consumed_copyon the temp's read, so the tail lowers to_5 = copy+retain _2.text; drop(_2); _0 = copy+take _5. The repro, the fixtureda_3080_tail_field_read_retains, and the build.w generated-source case all run clean under the debug allocator; the repro's output also changes from the wrongp2.w p2.wtop1.w p2.w.fix-ceremony: facts proven on the compiler, --check-with, and the src…
ehartford commentedon Nov 8, 2026
Fixed in #3079: the tail temp read retains (
materialize_tail_read_of_dropped_local→retain_consumed_copy); fixtureda_3080_tail_field_read_retains.seed.lock: nightly-20261110-local-1-d02ac04992f8 on the four gating p…