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 }}
Vec/iterator intrinsics (map, fold, ...) over a closure that may suspend ignore a cancellation unwind inside the closure #2019
Sema's settled call-site fact (#1985, call_site_may_suspend) records that this map call reaches a may-suspend closure. But the call lowers as a codegen intrinsic (VEC_MAP; likewise VEC_FOLD and the ITER_* adapters), and MirBuilder.call_may_cancel_return ignores every intrinsic except GENERIC_CALL and DYN_CALL. So when the fiber is cancelled inside the closure, the closure leaves by its cancellation unwind with no value. The intrinsic's loop calls it for the next element and builds the result from never-written slots, and the caller then resumes past the call. This is the #1985 class through intrinsic iteration.
Expected: the intrinsic loop stops when an invocation of the closure leaves by cancellation (FIBER_WAIT_CANCELLED after each invocation), releases what it built, and the call site takes the cancelled-return path. No Sema change is needed; the fact is already recorded.
Not fixed on wave-cancel: there the intrinsic tag was being read off the wrong call after #1985's check insertion. That is fixed, and these calls are back to main's behavior (no check).
wave-cancel: the eager Vec intrinsics (map, filter, fold) are fixed. MIR reads Sema's call_site_may_suspend for them, marks the call, and drops the partial result on the unwind edge; codegen leaves the loop at the invocation that unwound. Fixture: test/debug_alloc/da_2019_cancel_inside_intrinsic_closure.w.
Still open: a lazy adapter chain, e.g. let items: Vec[Item] = xs.iter().map(n => forever_item(n).await).collect() (the same fixture with that line), still reports DOUBLE FREE ... second_drop=drop#struct. The closure runs inside the terminal's *_NEXT emitters, and Sema's site fact is recorded on the map(..) node, not on the collect() that drives it. Needs: (1) Sema extends the site fact to a terminal whose receiver chain hands over a may-suspend callable; (2) the NEXT emitters stop (end the iteration) after an invocation that unwound, under a marked terminal; (3) the same for MIR-level for x in it.map(f) loops.
Activity
ehartford commentedon Oct 3, 2026
wave-cancel: the eager Vec intrinsics (map, filter, fold) are fixed. MIR reads Sema's call_site_may_suspend for them, marks the call, and drops the partial result on the unwind edge; codegen leaves the loop at the invocation that unwound. Fixture: test/debug_alloc/da_2019_cancel_inside_intrinsic_closure.w.
Still open: a lazy adapter chain, e.g.
let items: Vec[Item] = xs.iter().map(n => forever_item(n).await).collect()(the same fixture with that line), still reportsDOUBLE FREE ... second_drop=drop#struct. The closure runs inside the terminal's *_NEXT emitters, and Sema's site fact is recorded on themap(..)node, not on thecollect()that drives it. Needs: (1) Sema extends the site fact to a terminal whose receiver chain hands over a may-suspend callable; (2) the NEXT emitters stop (end the iteration) after an invocation that unwound, under a marked terminal; (3) the same for MIR-levelfor x in it.map(f)loops.An intrinsic call's tag goes on its own call, set before its terminat…
Vec map/filter/fold over a may-suspend closure stop at a cancellation…
An intrinsic call's tag goes on its own call, set before its terminat…
Vec map/filter/fold over a may-suspend closure stop at a cancellation…
A lazy adapter chain over a may-suspend closure stops at a cancellati…
An intrinsic call's tag goes on its own call, set before its terminat…
Vec map/filter/fold over a may-suspend closure stop at a cancellation…
A lazy adapter chain over a may-suspend closure stops at a cancellati…
An intrinsic call's tag goes on its own call, set before its terminat…
Vec map/filter/fold over a may-suspend closure stop at a cancellation…
A lazy adapter chain over a may-suspend closure stops at a cancellati…
Cancellation: indirect callees that may suspend get the cancelled-ret…
ehartford commentedon Oct 4, 2026
Fixed on main in 8cc883a (stack #2072, ten PRs; seed-driven battery GREEN on 92add22, tree identical to main).
The ListIter layer's parity with the retired intrinsics, and the susp…
Sema: a callable parameter or field suspends only when some caller ha…
sema, codegen: a List's adapters are its iterator's; the eager map/fi…