Skip to content

Futures that don't depend on Pollable while returning Poll::Pending crashes the runtime #69

@SilverMira

Description

@SilverMira

Currently, it seems that there is this assertion within the runtime.

assertion `left != right` failed: Attempting to block on an empty list of pollables - without any pending work, no progress can be made and wasi::io::poll::poll will trap

I'm not sure of the reasoning behind this assertion, since we really aren't interested in any pollables yet, and simply just want the runtime to run the next poll loop. But it's causing the runtime to crash in some scenarios which would run totally fine in other single-threaded async runtimes.

pub fn main() {
    wstd::runtime::block_on(async move {
        let (tx, mut rx) = tokio::sync::mpsc::channel(1);
        let fut_1 = async move {
            rx.recv().await;
            println!("received it");
        };
        let fut_2 = async move {
            tx.send(()).await;
            println!("sent it over");
        };

        futures::join!(fut_1, fut_2);
    });
}

Of course, this is a simple example, but in a more complex setup with tasks spawned through FuturesUnordered and channels communicating, it seems like scenarios where we aren't yet interested in waiting for a Pollable comes up quite often and will cause the runtime to crash

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