hyperlight-dev / hyperlight-dev/hyperlight

Fix guest logging `StackOverflow` issue

未关闭
#1,065 1 条评论 0 个 reaction 已指派 1 人 已被 @dblnz 认领 在 GitHub 查看
area/security lifecycle/confirmed
主要语言
Rust
星标
4.7k
派生
208
平均合并
1 天 7 小时
30 天内合并 PR
47

描述

### What happened?

When using logging in a hyperlight guest that enables the use of tracing crate with the `log` or `log-always` feature, the guest returns `StackOverflow`.
This especially impacts `hyperlight-wasm` because it uses the `log` feature of `tracing`.

### What did you expect to happen?

The expected behavior is for hyperlight to correctly receive the logs from the guest through the `OutBAction::Log` VMExit.

### Steps to reproduce the behavior

1. set `RUST_LOG="none,hyperlight_guest=trace,hyperlight_guest_bin=trace"`
2. run a hyperlight guest example
3. The guest returns `StackOverflow`

### Hyperlight Version

0.11.0

### OS version

```console
On Linux:
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

$ uname -a
Linux laptop 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 GNU/Linux

On Windows:
C:\> cmd /c ver
not tested but should behave the same

### Additional Information

When tracing is not enabled, the previous way of reporting logs, `outb` with `OutBAction::Log` action, calls [push_shared_output_data](https://github.com/hyperlight-dev/hyperlight/blob/main/src/hyperlight_guest/src/guest_handle/io.rs#L92) which is instrumented for logging/tracing. This `instrument` tries to send a new log again, this results in an infinite `loop` that produces the `StackOverflow`.

The reason for this issue is the `log_message` function call that reports the message to the host, more specifically the [hyperlight_guest/src/host_comm.rs#L196](https://github.com/hyperlight-dev/hyperlight/blob/main/src/hyperlight_guest/src/guest_handle/host_comm.rs#L196), that uses the `input/output` buffer for the log.

The simple solution is to remove the `instrument` from the `push_shared_output_data`, the correct solution is to use the same `event batching` logic and buffer as the tracing uses.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。