Skip to content

A Task used after join_cleanup() is accepted, and the ownership validator does not flag the copy of the moved handle #1993

Closed

Description

@ehartford

Found while fixing #1990 (branch wave-cancel, after its fix lands).

join_cleanup cancels the task, awaits its cleanup and frees its result buffer: it releases the handle, and since #1990 the MIR moves an owned Task binding into the cleanup await. But Sema types it as an observer (check_method_call "Task/ScopedTask surface methods", SemaCheck.w: returns Unit, never marks the receiver moved), so a later use is accepted:

use std.task.Task
async fn word() -> str: "hello" ++ " world"
async fn main:
    let t = word()
    t.join_cleanup()
    let s = t.await
    print(s)
  • with check --validate-all: validate-all: ok. The MIR reads copy _1 after move _1; the ownership validator does not report a use of a Moved local (a tool that stayed silent).
  • run --debug-alloc (WITH_ALLOC_NO_REUSE=1): prints an empty line, leak count=0. An await of a released handle produced a value.

Two questions for a ruling, since join_cleanup is not in the specification at all (no hit under docs/spec): is it user surface (then §14.7 should state that it consumes the Task, and Sema marks the receiver moved: a use after it is "use of moved value"), or library-internal (then user code should not reach it)?

Independently of the ruling: the ownership validator should reject a copy/move of a local whose state is Moved on that path.

Activity

  1. ehartford commented on Oct 4, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in 8cc883a (stack #2072, ten PRs; seed-driven battery GREEN on 92add22, tree identical to main).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions