Repository navigation
Conversation
added 3 commits
October 2, 2026 20:07
…on (#916) An async caller cancelled while suspended inside a sync callee that awaits (`tasks |> await_all`, `eat(tasks)`) resumed past the call and consumed the callee's never-written return slot: the debug allocator reported "invalid free: pointer is not an allocated payload start" from `__drop_enum_*` at spec_ss14_11_await_combinator_cancel_joins.w:33 (await_all_result_parent), and a Drop result ran its destructor on garbage. The cancelled-return protocol (§14.7) lived only at await sites. - Sema settles which fn declarations may suspend once checking is done (settle_may_suspend_facts: a least fixpoint over every body, keyed by declaration node, so cycles cannot cut it short and a specialization shares its template's answer). The walker now sees a pipeline stage's callee (it walked d1/d2 of NK_PIPELINE and missed both the piped value and the resolved stage). - MirLower: a TK_CALL whose Sema-resolved callee (the call contract's symbol, else the fn constant) is a sync fn that may suspend continues into a FIBER_WAIT_CANCELLED check; set, the caller takes the cancelled return (set flag, defers, drops, return) before the result is read, exactly as the await it sits under. Async and gen callees spawn/build and never suspend the caller. - emit_defers_for_range runs each defer body with only the defers registered before it pending, so a cancellation unwind inside a defer runs those and not itself: an `.await` inside a defer no longer recurses the lowering into a stack overflow (`with check` SIGSEGV). - struct_field_type is a reader (`fn`, not `mut fn`); the seed flagged update_string_fields_after_aggregate's `count` view once lowering's call graph grew. Tests: da_916_cancel_unwinds_through_sync_callee (direct + generic pipeline callee; red before: resumed=2 batch_drops=1), and the #916 known-issue/skip-on directives are gone from the ss14_11 cancel test, which now passes for the right reason on every host.
Contributor
Author
|
Battery GREEN on stack top 1033f91 (seed-driven, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #916. Debug allocator + lldb:
let _ = tasks |> await_alldropped theResult[Vec[i32], str]that a cancelledawait_allnever returned (invalid free, __drop_enum). MIR went straight from the call to the drop. Now Sema settles may-suspend once per declaration (generic specializations use the template's answer; pipeline stages and piped values counted), and MIR gives every call Sema says may suspend the await's cancelled-return check, on the existing emit_cancelled_return path, via terminate_with_span with Sema's resolved callee. Each defer body runs with only the defers registered before it pending (fixes an existingwith checkstack overflow on.awaitinside adefer). spec_ss14_11_await_combinator_cancel_joins.w passes for the right reason; its known-issue and linux-aarch64 skip lines are removed. Fixtures da_916_cancel_unwinds_through_sync_callee.w and behav_await_inside_defer.w red→green; 86 async/cancel fixtures ok; debug-alloc lane 146/146; drop-audit 254/0; gate green. Follow-ups filed: indirect calls (closure/dyn/fn value) and cancellation inside a defer during break/continue unwind. Bottom of the #1960 stack.