Skip to content

Memory holding schedule function might be freed during its invocation #11

Closed
@tmiasko

Description

@tmiasko

Currently waking the waker by value hands over the ownership of the task to the
schedule without retaining any refcount on its own. Once the scheduling
function hands over the ownership of task further there is no guarantee that
memory that holds scheduling function will remain valid.

For example (drop(task) is used to avoid irrelevant complexity):

fn main() {
    let s = "1234".to_owned();

    let (task, _) = async_task::spawn(
        async {},
        move |task| {
            println!("{:?}", s);
            drop(task);
            println!("{:?}", s);
        },
        (),
    );
    task.schedule();
}

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