fix(sandbox): fix data corruption in sync --down and hang in sync --up#93
Merged
fix(sandbox): fix data corruption in sync --down and hang in sync --up#93
Conversation
The sandbox SSH server used tokio::spawn fire-and-forget for each stdout/stderr chunk, which provided no ordering guarantee under tokio's work-stealing scheduler. Under load, chunks arrived out-of-order, corrupting tar streams during download. Replace tokio::spawn with runtime.block_on() to ensure each chunk is fully sent before reading the next. Remove AsyncWriteExt::shutdown() from the SSH proxy's copy helper to prevent gateways from treating TCP half-close as full-close and truncating in-flight downloads. Implement channel_eof handler on the sandbox SSH server to close the child process stdin when the client signals EOF. Without this, commands like 'cat | tar xf -' used by sync --up would hang waiting for stdin EOF indefinitely. Add ValueHint::AnyPath to the --up argument for shell completion. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
Add Rust unit tests verifying that dropping the mpsc sender (the mechanism channel_eof uses) closes the child's stdin pipe and delivers all buffered data before EOF. These tests would hang without the channel_eof fix. Add a 512 KiB large-file round-trip to the E2E sync bash test with SHA-256 checksum verification. Small test files fit in a single SSH chunk and cannot trigger the data ordering bug that corrupted tar streams. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
eaa2c07 to
2f2edad
Compare
drew
approved these changes
Mar 4, 2026
drew
pushed a commit
that referenced
this pull request
Mar 16, 2026
#93) The sandbox SSH server used tokio::spawn fire-and-forget for each stdout/stderr chunk, which provided no ordering guarantee under tokio's work-stealing scheduler. Under load, chunks arrived out-of-order, corrupting tar streams during download. Replace tokio::spawn with runtime.block_on() to ensure each chunk is fully sent before reading the next. Remove AsyncWriteExt::shutdown() from the SSH proxy's copy helper to prevent gateways from treating TCP half-close as full-close and truncating in-flight downloads. Implement channel_eof handler on the sandbox SSH server to close the child process stdin when the client signals EOF. Without this, commands like 'cat | tar xf -' used by sync --up would hang waiting for stdin EOF indefinitely. Add ValueHint::AnyPath to the --up argument for shell completion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tokio::spawnfire-and-forget for each stdout/stderr chunk, which provided no ordering guarantee under tokio's work-stealing scheduler. Under load, chunks arrived out-of-order, corrupting tar streams. Replaced withruntime.block_on()to ensure sequential delivery.SshHandlernever implementedchannel_eof. Without it, the child process stdin was never closed when the client signaled EOF, socat | tar xf -waited indefinitely. Addedchannel_eofhandler that drops the input sender.ValueHint::AnyPathto the--upargument for shell path completion.Test Plan
channel_eofuses) closes the child's stdin pipe and delivers all buffered data before EOF. Tests use a 5s timeout and would hang without the fix.cargo test -p navigator-sandboxpasses (169 tests).