async-std icon indicating copy to clipboard operation
async-std copied to clipboard

Spawned write to file never finishes when running single threaded

Open Jonathas-Conceicao opened this issue 4 years ago • 3 comments

I've recently had a issue when running a application on a single core machine (an old Raspberry Pi) where a Future would never finish. I have managed to reproduce the problem with the following small example on x64 as well:

use async_std::{fs, io::prelude::WriteExt};

#[async_std::main]
async fn main() {
    let handle = async_std::task::spawn(async {
        let mut handle = fs::OpenOptions::new()
            .create(true)
            .write(true)
            .open("/tmp/foo")
            .await
            .unwrap();
        handle.write_all(&[0; 313]).await.unwrap();
        println!("Future finished!");
    });

    handle.await;
}

If this is executed while setting ASYNC_STD_THREAD_COUNT=1 the application doesn't finish. If I instead write to something else (like a Vec) the application finishes as expected. Additionally if I use async_std::task::spawn_local instead of spawnor just await the future in the main thread, the application also finishes as expected.

Here's the toml file:

[package]
name = "testing_async_std"
version = "0.1.0"
edition = "2018"

[dependencies]
async-std = { version = "=1.9.0", features = ["attributes"] }

Jonathas-Conceicao avatar May 21 '21 15:05 Jonathas-Conceicao

I did some testing changing version numbers of async-std and I've found that using the version "=1.6.2" worked as expected, while version "=1.6.3" and newer would reproduce this issue.

Jonathas-Conceicao avatar May 21 '21 15:05 Jonathas-Conceicao

The "1.6.3" changed the executor. This might explain the behavior change.

otavio avatar May 21 '21 18:05 otavio

@dignifiedquire please take a look at this; this is a regression.

otavio avatar Aug 24 '21 11:08 otavio