Skip to content

Reading from STDIN fails when Debug logging is enabled. #1757

Open
@jounathaen

Description

@jounathaen

Example program:

#[cfg(target_os = "hermit")]
use hermit as _;
use std::io;

fn main() {
    println!("input please!");
    let mut buffer = String::new();
    if let Ok(_) = io::stdin().read_line(&mut buffer) {
        print!("{}", buffer);
    } else {
        eprintln!("No input provided or an error occurred.");
    }
}

compile (with strace feature enabled but makes no difference): HERMIT_LOG_LEVEL_FILTER=Debug cargo build --target x86_64-unknown-hermit

Output:

...
[0][INFO] Jumping into application
[0][DEBUG] Switching FPU owner from task 0 to 1
[0][WARN] Unable to read entropy! Fallback to a naive implementation!
sys_malloc(size = 1024, align = 1) = 0x400000011f80
sys_write(fd = 1, buf = 0x1d362dd, len = 14) = input please!
14
sys_malloc(size = 8192, align = 1) = 0x400000012400
sys_read(fd = 0, buf = 0x400000012400, len = 8192) = [0][DEBUG] Blocking task 1
[0][DEBUG] Only Idle Task is available.
[0][DEBUG] Switching task from 1 to 0 (stack 0x40000301DF60 => 0x11908)

Note, that sys_read doesn't return, so apparently, the debug prints lead to the read syscall to block.

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