hermit-os / hermit-os/kernel

Reading from STDIN fails when Debug logging is enabled.

Open
#1,757 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
132
Avg merge
1d 14h
Merged PRs (30d)
39

Description

Example program:

```rust
#[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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.