fix: avoid PTY wait deadlock on wait errors#165
Merged
branchseer merged 7 commits intomainfrom Feb 16, 2026
Merged
Conversation
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
Arc<std::io::Error>in the sharedOnceLock(Result<ExitStatus, Arc<std::io::Error>>) so error state is shareable without synthetic fallback status.ChildHandle::wait()to returnanyhow::Result<ExitStatus>and propagate wait failures through callers.pty_terminal_test, milestone tests, andvite_task_bine2e harness) to consume the newanyhow::Resultreturn type.#[timeout(5000)]and run them without a Windows serialization guard.Stable Reproduction (before fix)
To deterministically reproduce the real deadlock path (without mocking
child.wait()return values), I used a temporary Windows-only repro patch that swaps the internalWinChildprocess handle with a non-process handle (CreateEventWevent handle). This makeschild.wait()execute the real Windows wait/get-exit-code path and returnErr.With the old code path (
if let Ok(status) = child.wait() { ... }),OnceLockwas never set on error, andChildHandle::wait()blocked forever.Repro command:
Observed behavior under repro:
#[timeout(15000)]#[timeout(60000)]That demonstrates timeout-independent deadlock behavior.
Why this fixes it
OkorErr).ChildHandle::wait()cannot block forever on an unsetOnceLock.ExitStatus::with_exit_code(1)).Validation
cargo clippy -p pty_terminal --all-targets --all-features -- -D warningscargo test -p pty_terminal -p pty_terminal_testcargo test -p vite_task_bin --test e2e_snapshots --no-runcargo xtest --builder cargo-xwin --target x86_64-pc-windows-msvc -p pty_terminal --test terminalcargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p pty_terminal --test terminalcargo xtest --builder cargo-xwin --target x86_64-pc-windows-msvc -p pty_terminal --test terminalrepeated 40 times (all green, without serial guard)