hluk run: non-UTF-8 bytes in guest stdout reach the host as U+FFFD
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Find the write host function and trace how Console echoes guest output through GuestOutput and Console::emit; the issue names these entry points but no file paths. First inspect the raw-byte handling and the captured-output path (take_output / drain_output). Add a regression test based on the provided printf '\377\376x' repro; done means the CLI preserves those bytes while captured output remains a String.
索引モデルが issue の本文から書いたものです。
説明
Bug: hluk run replaces non-UTF-8 bytes in guest stdout with U+FFFD
What happens
A guest program that writes bytes that aren't UTF-8 to stdout doesn't get those bytes through to the host's stdout. Each invalid byte arrives as U+FFFD (ef bf bd).
Repro (hluk 0.21.0, x86_64 Linux, GitHub Actions runner with KVM)
Inside the guest, the bytes are intact:
$ hluk run --runtime bash --exec "printf '\377\376x' | od -An -tx1"
ff fe 78
Piped out to the host, they're replaced:
$ hluk run --runtime bash --exec "printf '\377\376x'" | od -An -tx1
ef bf bd ef bf bd 78
Expected: ff fe 78 in both cases.
Cause
The write host function receives raw bytes (its doc comment says "Bytes, not a string: what a program writes need not be UTF-8"), but Console decodes them through GuestOutput before echoing them, and Console::emit writes the decoded text with print!/eprint!. GuestOutput documents that "bytes that are not UTF-8 read as U+FFFD", so the replacement looks intended for the captured text. For the echo to the CLI's own stdout and stderr, though, it means any binary output can't get through: gzip -c, tar c, images, protobuf, or a program printing Latin-1.
Proposed fix
When echo is on, write the guest's bytes to the host's stdout/stderr as they are (std::io::stdout().write_all(&bytes) plus flush), and keep decoding only for the captured output (take_output / drain_output), so the library API stays String and doesn't change. Two notes:
- A failed write to stdout currently panics through
print!, which is what makeshluk run | head -1end with its reader. The byte path would keep that behaviour. - A character split across two writes needs no special handling in the echo path, because the bytes simply go out in order.
A bytes accessor for captured output (next to take_output) could be a separate follow-up if that's wanted.
I'm happy to send a PR for the echo-path change, with a test along the lines of the repro above, if this approach sounds right to you.
- 主要言語
- Rust
- スター
- 77
- フォーク
- 14
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hyperlight-dev/hyperlight-unikraft のほかの issue
-
dependencies
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
hyperlight-dev/hyperlight-unikraft#136 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
ci/nightly
難易度 4/5 3〜5日 初心者へのやさしさ 53/100
hyperlight-dev/hyperlight-unikraft#306 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ci/nightly
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
hyperlight-dev/hyperlight-unikraft#305 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ci/nightly
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
hyperlight-dev/hyperlight-unikraft#304 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
hostnet: a port-0 bind can collide with another listener's guest port under the listener redirectオープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
hyperlight-dev/hyperlight-unikraft#294 ·
メンテナーはふだん 1 日以内に返信
hyperlight-dev/hyperlight-unikraft の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
jelmer/buildlog-consultant#364 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
solutionscay/skiff#310 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
valkey-io/valkey-large-object#222 ·
メンテナーはふだん 1 日以内に返信
-
bug user-priority/P1
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信