Skip to content

fix(vmm): resolve musl CRT mismatch crash and improve startup diagnostics#372

Merged
DorianZheng merged 2 commits intomainfrom
fix/musl-linker-crash-and-diagnostics
Mar 12, 2026
Merged

fix(vmm): resolve musl CRT mismatch crash and improve startup diagnostics#372
DorianZheng merged 2 commits intomainfrom
fix/musl-linker-crash-and-diagnostics

Conversation

@DorianZheng
Copy link
Copy Markdown
Member

Summary

  • Root cause fix: Removed linker = "x86_64-linux-musl-gcc" from project .cargo/config.toml — Ubuntu's system musl CRT (v1.2.2) was ABI-incompatible with Rust's bundled musl CRT, causing the guest binary to crash at startup with exit code 0 and no output
  • ELF pre-flight validation: New guest_check.rs validates guest binary architecture and static linking before ext4 injection, catching mismatches early with clear error messages
  • Enhanced crash diagnostics: Exit-code-0 interpretation, console.log analysis (empty/kernel-only/guest-output), and actionable diagnostic commands in crash reports
  • macOS cross-compile support: Moved musl-cross linker config to per-user ~/.cargo/config.toml (via setup-macos.sh) and added env var fallback in build-guest.sh

Test plan

  • cargo test -p boxlite --lib -- guest_check (8 tests pass)
  • cargo test -p boxlite --lib -- crash_report (all tests pass)
  • cargo clippy -p boxlite --tests -- -D warnings (clean)
  • cargo fmt --check (clean)
  • Linux end-to-end: boxlite run alpine:latest -- echo hellohello (boxlite-dev GCE)

DorianZheng and others added 2 commits March 12, 2026 20:50
…tics

On Linux, the project .cargo/config.toml specified `linker = "x86_64-linux-musl-gcc"`
which forced Ubuntu's system musl CRT objects (v1.2.2), creating an ABI mismatch
with Rust's bundled musl CRT. This caused the guest binary to crash at startup
with exit code 0 and no output.

Changes:
- Remove linker directives from project .cargo/config.toml so Linux uses Rust's
  self-contained musl linking (macOS still needs musl-cross, configured per-user)
- Add setup_musl_linker() to setup-macos.sh for per-user ~/.cargo/config.toml
- Add macOS linker env var fallback in build-guest.sh
- Add guest_check.rs: ELF pre-flight validation (arch, static linking) before
  injecting guest binary into rootfs ext4 image
- Enhance crash_report.rs: exit-code-0 interpretation, console.log analysis
  (empty/kernel-only/guest-output), actionable diagnostic commands
- Fix latent bug: create logs_dir in box filesystem layout
- Promote console output log from debug to info in krun engine

Tested on Linux (boxlite-dev GCE): `boxlite run alpine:latest -- echo hello` → hello
@DorianZheng DorianZheng merged commit 0d4fa8d into main Mar 12, 2026
17 checks passed
@DorianZheng DorianZheng deleted the fix/musl-linker-crash-and-diagnostics branch March 12, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant