Fix hang on SIGINT when I/O pipes are broken#595
Open
d-e-s-o wants to merge 1 commit intocontainers:mainfrom
Open
Fix hang on SIGINT when I/O pipes are broken#595d-e-s-o wants to merge 1 commit intocontainers:mainfrom
d-e-s-o wants to merge 1 commit intocontainers:mainfrom
Conversation
Fix two bugs that cause the host process to hang at 100% CPU when SIGINT is delivered while the I/O pipes are broken (e.g., when the parent process dies after Ctrl+C). The hang has two contributing factors: 1. The TX thread spins when a pipe breaks. write_desc_to_output returns Err(BrokenPipe), but the error arm only logs and continues the loop. After the loop, bytes_written == 0 causes undo_pop, and pop_head_blocking immediately returns the same descriptor, creating a tight spin. Fix this by returning from process_tx on write error. 2. The RX pop_head_blocking never checks the stop flag. Port::shutdown sets stop=true and unparks the RX thread, but the thread parks again without checking stop, so join hangs forever. Fix this by checking the stop flag after signal_used_queue in the None branch and returning None to the caller. Signed-off-by: Daniel Müller <deso@posteo.net>
a4d196d to
51e94a6
Compare
Contributor
Author
|
I did verify that I was no longer reproduce the hangs/stray threads with the fix. Also, 60c6756 contains a vibe-coded test that Claude assures me reproduces the issue. I did verify it failed before and succeeds now, but haven't looked at it closely otherwise, as I am not sure we want to land it. |
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.
Fix two bugs that cause the host process to hang at 100% CPU when SIGINT is delivered while the I/O pipes are broken (e.g., when the parent process dies after Ctrl+C).
The hang has three contributing factors: