Skip to content

std::io::Write::write_vectored() to io::stdout() does not produce all expected lines. #68041

Closed
@rustyconover

Description

@rustyconover

When trying to write an array of 8192 IoSlices consisting of "1" followed by "\n" only the first character is written on Mac OS X.

use std::io;
use std::io::prelude::*;
use std::io::IoSlice;

fn main() {
    let mut write_array: Vec<IoSlice> = Vec::new();
    for _ in 1..1024 * 4 {
        write_array.push(IoSlice::new(b"1"));
        write_array.push(IoSlice::new(b"\n"));
    }
    io::stdout().write_vectored(&write_array).unwrap();
    io::stdout().flush().unwrap();
}

Output:

1

Just one byte is written:

./target/debug/vector-bug | wc 
       0       1       1

I expected 4096 pairs of "1\n" to be written.

Meta

$ rustc --version --verbose
rustc 1.40.0 (73528e339 2019-12-16)
binary: rustc
commit-hash: 73528e339aae0f17a15ffa49a8ac608f50c6cf14
commit-date: 2019-12-16
host: x86_64-apple-darwin
release: 1.40.0
LLVM version: 9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions