hluk run: non-UTF-8 bytes in guest stdout reach the host as U+FFFD

オープン
#293 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@enilsen16 がすでに取り組んでいます。

2026年12月2日 から。

  • #307 @enilsen16 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
backend, cli

調査の方向性

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

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 makes hluk run | head -1 end 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hyperlight-dev/hyperlight-unikraft のほかの issue

hyperlight-dev/hyperlight-unikraft の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。