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
MIR / Codegen (§14.6): consuming an owned resource inside an async: block double-drops it in the enclosing frame #3044
Found via --debug-alloc and --dump-drop-plan while verifying #3038.
Minimal reproduction
use std.channel.chan
fn main:
let (tx, rx) = chan[str](4)
async scope s =>
s.track(async:
tx.send("hello")
drop(tx)
)
s.track(async:
for msg in rx:
print(msg)
)
Actual (--debug-alloc + --dump-drop-plan)
drop(tx) inside the async: block releases the Sender[str] ($anonymous$...: drop(_1) @ std.drop _1), and main still drops _3 (tx) at scope exit (main: state_before=Init action=drop text="drop(_3)"), panicking with invalid free in with_channel_release_sender.
Root cause
Spec §14.6 states: "async: blocks follow the same capture rules as closures." In src/MirLower.w:16815-16837, closures (!is_async) capture non-Copy locals by place (MIR_CAPTURE_PLACE_REF) and mark consumed locals with mark_local_ever_moved (16813) so reset-on-move blanks the outer binding through the capture pointer and keeps the null guard on the outer scope-exit drop. async: blocks (is_async, 16827-16835) instead copy raw bits (MIR_CAPTURE_LOCAL) into the heap env struct without MIR_CAPTURE_PLACE_REF or blanking the outer local when consumed.
Activity
#3044, #3046, #3047 (Gap 1), #3048, #3049: five spec-gap fixes from the
ehartford commentedon Nov 6, 2026
Fixed in #3054 (merged as 12489f1).