Skip to content

multiple write! on async_std::fs::File can trigger infinite process #964

@hn3000

Description

@hn3000

By writing two short strings with separate write! invocations we can trigger an infinite process
that will continue writing the start of the second string until the process is killed or the disk is full.

    println!("starting ...");

    let mut file = OpenOptions::new()
                .append(true)
                // .write(true)    // also happens with write, write+truncate
                // .truncate(true)
                .create(true)
                .open(filename).await?;

    write!(
        &mut file, 
        "{}", 
        a, 
    ).await?;
    write!(
        &mut file, 
        "{}", 
        b, 
    ).await?;
    
    println!("done.");

As long as the second string b is shorter than the first one (a) we can't reproduce the problem, with a longer than 8 bytes we can reliably reproduce the problem.

Full reproduction in this gist: https://gist.github.com/hn3000/100460d1e239f22bf3862f1a8f8cfd92

(Also, I am not sure how to write a failing unit test because the error case does not terminate.)

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