Skip to content

fix(shim): write exit_file when main() returns Error (exit code 1)#232

Merged
DorianZheng merged 1 commit intoboxlite-ai:mainfrom
uran0sH:shim-error
Feb 12, 2026
Merged

fix(shim): write exit_file when main() returns Error (exit code 1)#232
DorianZheng merged 1 commit intoboxlite-ai:mainfrom
uran0sH:shim-error

Conversation

@uran0sH
Copy link
Copy Markdown
Contributor

@uran0sH uran0sH commented Feb 11, 2026

This pull request (#227) is excellent, providing very user-friendly error messages, but it didn't handle the situation where the shim process exits with error code 1. This pull request addresses this issue.

Changes:

  • Add ExitInfo::Error variant for normal error returns (exit code 1)
  • Update CrashReport to handle Error type with user-friendly message
  • Refactor shim/main() to capture run_shim() errors and write exit_file
  • main() now writes exit_file before returning Err(e)

Now all three exit paths write exit_file:

  • Panic (exit code 101) → ExitInfo::Panic
  • Signal (exit code 128+N) → ExitInfo::Signal
  • Normal error (exit code 1) → ExitInfo::Error (when main returns Err)

Previously, exit_file was only written on panic (exit code 101) or
signal (exit code 128+N), but not when main() returned a normal
Result::Err with exit code 1. This meant the main process couldn't
get detailed error information when the shim exited normally with an error.

Changes:
- Add ExitInfo::Error variant for normal error returns (exit code 1)
- Update CrashReport to handle Error type with user-friendly message
- Refactor shim/main() to capture run_shim() errors and write exit_file
- main() now writes exit_file before returning Err(e)

Now all three exit paths write exit_file:
- Panic (exit code 101) → ExitInfo::Panic
- Signal (exit code 128+N) → ExitInfo::Signal
- Normal error (exit code 1) → ExitInfo::Error (when main returns Err)

Signed-off-by: Wenyu Huang <[email protected]>
@uran0sH
Copy link
Copy Markdown
Contributor Author

uran0sH commented Feb 11, 2026

Old msg:

The VM exited unexpectedly.

Common causes:
• AppArmor or SELinux blocking execution
• /dev/kvm permissions (Linux)
• Missing Hypervisor entitlement (macOS)

Debug files:
• Console: /home/huangwenyu/.boxlite/boxes/01KH6T4AAJ1ENHX6HXR8ZQ1TKE/console.log

Tip: Check system logs (dmesg, Console.app)

New msg:

The shim process exited with an error.

Error: engine reported an error: VM failed to start with status -2

Debug files:
• Console: /home/huangwenyu/.boxlite/boxes/01KH6SJKTGDQNG9VX019MMF2BW/console.log
• Stderr:  /home/huangwenyu/.boxlite/boxes/01KH6SJKTGDQNG9VX019MMF2BW/shim.stderr box_id=01KH6SJKTGDQNG9VX019MMF2BW task=guest_connect

@DorianZheng DorianZheng merged commit 2e6c4d3 into boxlite-ai:main Feb 12, 2026
14 checks passed
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.

2 participants