Skip to content

fix(guest): fd double-close in spawn_with_pipes causing exec crash#268

Merged
DorianZheng merged 1 commit intomainfrom
fix/guest-exec-fd-double-close
Feb 15, 2026
Merged

fix(guest): fd double-close in spawn_with_pipes causing exec crash#268
DorianZheng merged 1 commit intomainfrom
fix/guest-exec-fd-double-close

Conversation

@DorianZheng
Copy link
Copy Markdown
Member

@DorianZheng DorianZheng commented Feb 15, 2026

Summary

  • Fix BOXLITE_EXECUTOR=guest causes transport error #264
  • Fix file descriptor double-close bug in GuestExecutor::spawn_with_pipes() that crashed the guest agent on every exec call
  • Root cause: nix 0.29's pipe() returns (OwnedFd, OwnedFd), but the code used as_raw_fd() (borrow) instead of into_raw_fd() (transfer ownership) when passing fds to Stdio::from_raw_fd(), creating dual ownership and triggering Rust's IO safety abort
  • Switch to into_raw_fd() and remove the now-unnecessary drop() calls

Test plan

  • cargo check -p boxlite-guest --target aarch64-unknown-linux-musl passes
  • boxlite exec -e BOXLITE_EXECUTOR=guest <box> -- echo "Hello World" prints output (previously crashed with transport error)
  • boxlite exec <box> -- echo "Hello from container" still works (container executor regression check)

nix 0.29's pipe() returns (OwnedFd, OwnedFd). The code passed these
to Stdio::from_raw_fd() via as_raw_fd(), which borrows without
transferring ownership. Both OwnedFd and Stdio then owned the same fd,
triggering "IO Safety violation: owned file descriptor already closed"
when the OwnedFd was dropped.

Switch to into_raw_fd() to properly transfer ownership, and remove the
now-unnecessary drop() calls.
@DorianZheng DorianZheng merged commit 938aaad into main Feb 15, 2026
14 checks passed
@DorianZheng DorianZheng deleted the fix/guest-exec-fd-double-close branch February 15, 2026 00:09
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.

BOXLITE_EXECUTOR=guest causes transport error

1 participant