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
Cancellation protocol gap: async caller of a sync-but-suspending fn uses the cancelled callee's garbage return (invalid free) #916
async fn tick() -> i32: 1
fn eat[T](tasks: impl IntoIter[Task[T]]) -> Vec[T]: // SYNC fn that suspends via awaits inside
let pending: Vec[Task[T]] = Vec.new()
for task in tasks.into_iter(): pending.push(task)
let values: Vec[T] = Vec.new()
while pending.len() > 0:
values.push(pending.remove(0).await)
values
async fn parent -> i32:
let tasks: Vec[Task[i32]] = Vec.new()
tasks.push(wait_forever(1))
tasks.push(wait_forever(2))
let _ = tasks |> eat // parent suspends INSIDE eat
0
// main: spawn parent, drive, parent.cancel(), parent.join_cleanup()
invalid free: pointer is not an allocated payload start from __drop_struct_94 (= Vec[i32]).
Root cause (MIR-verified)
The cancelled-return protocol lives only at AWAIT sites (lower_single_await: FIBER_IS_CANCELLED / FIBER_WAS_CANCELLED_RETURN checks, unwind bb, FIBER_SET_CANCELLED_RETURN before TK_RETURN — src/MirLower.w:7842-7948). When the suspension happens inside a SYNC callee, that callee's await unwinds it correctly and returns with cancelled_return set — but the ASYNC CALLER has no post-call check: parent's MIR is call eat(move _1) -> _8; _7 = move _8; drop(_7) unconditionally. _8 was never written (the callee unwound), so the caller moves and drops stack garbage — the invalid free.
Pre-existing and older than the current seed (the seed cannot even compile the old combinator bodies to reach this path); it was one component of the red pinned on ss14_11's cancel test.
Fix shape
After any call whose callee MAY SUSPEND (sema's may-suspend effect — the §14 arena-scope machinery already tracks it), an async/generator caller must branch on FIBER_CANCELLED_RETURN: skip result consumption and unwind (defers + drops + set-cancelled-return + return), mirroring lower_single_await's unwind bb. Emit only for may-suspend callees so ordinary calls pay nothing. Acceptance: spec_ss14_11_await_combinator_cancel_joins (currently re-pinned to this issue) goes green; a da_ fixture pins the caller-side protocol with counted drops.
Found finishing D33/#724 — the combinators' own double-own is fixed; this is the residual on the cancel path only.
Nondeterminism evidence, 2026-09-07: test/spec/spec_ss14_11_await_combinator_cancel_joins.w carries known-issue: #916 and stays red on every selfhost-linux-aarch64 run on main (the harness prints "red as expected"), but in the nightly release workflow's linux-aarch64 job on branch windows-release-uat (run 34141543229, same tree as its green PR lane, seed v0.15.2.0) it passed, so the harness failed the file: "known-issue #916 expected this test to stay red, but it passed". The cancel/join outcome this fixture pins is therefore timing-dependent on the arm64 hosted runner, not stably wrong. Nothing in this run's tree touched async or fibers. The nightly jobs now upload out/test-graph/** on failure so the next occurrence carries the file's stdout/stderr.
Platform note from the release work (2026-09-16): on linux-aarch64 this issue does not reproduce. Built main (0a0ff13) natively in a linux/arm64 container (ubuntu 24.04, the lane's SDK/seed/runtime), native-spec-tests ran 210 files and the only failure was test/spec/spec_ss14_11_await_combinator_cancel_joins.w — and it failed the known-issue gate, not the test:
error: known-issue #916 async caller of a cancelled sync-but-suspending callee consumes its garbage return
expected this test to stay red, but it passed; if the issue is fixed, remove the known-issue directive
So the garbage-return consumption is arch-dependent (it still reproduces on darwin-aarch64 and linux-x86_64 per the passing known-issue gate there). The release PR (#1155) scopes the test with skip-on: linux-aarch64 so that leg's battery can be green; when #916 is fixed, drop both directives.
Activity
std: D33 naming pair lands — IntoIter consumes, Iterable borrows; com…
ehartford commentedon Sep 7, 2026
Nondeterminism evidence, 2026-09-07:
test/spec/spec_ss14_11_await_combinator_cancel_joins.wcarriesknown-issue: #916and stays red on every selfhost-linux-aarch64 run onmain(the harness prints "red as expected"), but in the nightly release workflow's linux-aarch64 job on branchwindows-release-uat(run 34141543229, same tree as its green PR lane, seed v0.15.2.0) it passed, so the harness failed the file: "known-issue #916 expected this test to stay red, but it passed". The cancel/join outcome this fixture pins is therefore timing-dependent on the arm64 hosted runner, not stably wrong. Nothing in this run's tree touched async or fibers. The nightly jobs now uploadout/test-graph/**on failure so the next occurrence carries the file's stdout/stderr.ehartford commentedon Sep 16, 2026
Platform note from the release work (2026-09-16): on linux-aarch64 this issue does not reproduce. Built main (0a0ff13) natively in a
linux/arm64container (ubuntu 24.04, the lane's SDK/seed/runtime),native-spec-testsran 210 files and the only failure wastest/spec/spec_ss14_11_await_combinator_cancel_joins.w— and it failed the known-issue gate, not the test:So the garbage-return consumption is arch-dependent (it still reproduces on darwin-aarch64 and linux-x86_64 per the passing known-issue gate there). The release PR (#1155) scopes the test with
skip-on: linux-aarch64so that leg's battery can be green; when #916 is fixed, drop both directives.release: c_import generator fixes for the UAT packages, local-first r…
release: make every Release leg able to go green (toward v0.15.2.2 wi…
rt/MIR: cancellation cuts a parked channel wait short and the fiber u…
rt/MIR: select await no longer hangs on a loser parked in recv() — ca…
Cancellation: a call to a sync fn that may suspend unwinds its cancel…
A cancellation inside a defer on a break/continue path drops only wha…
A call through a closure, a fn value or a dyn method unwinds its call…
#2011's pre-existing validate-all reds, each at its root (#2011)
A cancellation inside a defer on a break/continue path drops only wha…
A call through a closure, a fn value or a dyn method unwinds its call…
#2011's pre-existing validate-all reds, each at its root (#2011)
A cancellation inside a defer on a break/continue path drops only wha…
A call through a closure, a fn value or a dyn method unwinds its call…
#2011's pre-existing validate-all reds, each at its root (#2011)
A cancellation inside a defer on a break/continue path drops only wha…
A call through a closure, a fn value or a dyn method unwinds its call…
#2011's pre-existing validate-all reds, each at its root (#2011)
Cancellation: indirect callees that may suspend get the cancelled-ret…