Skip to content

stdin cannot be read #1434

@koivunej

Description

@koivunej

I tried to run my stdin reading program yesterday with miri 0.1.0 (10419b3 2020-05-11) and rustc 1.45.0-nightly (a74d1862d 2020-05-14) but upon reading the stdin Ok(0) seems to be always returned at least on Linux.

Example:

use std::io::Read;

fn main() {
    let mut bytes = [0u8; 8192];
    let total = std::io::stdin().lock().read(&mut bytes[..]).unwrap();
    println!("{}", total);
}

With stable echo foo | cargo run prints 4.
With miri echo foo | cargo +nightly miri run -- -Zmiri-disable-isolation prints 0. Same for reading in a loop.

Looking at src/shims/foreign_items/posix.rs and src/shims/fs.rs I can't at least see any relevant TODO's or other notes which would suggest this should not work.

Could this be because src/bin/cargo-miri.rs launches a subprocess and somehow the stdin does not get inherited?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-shimsArea: This affects the external function shimsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementE-good-first-issueA good way to start contributing, mentoring is available

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions