Allow async exceptions to pierce masked waitForProcess#101
Merged
snoyberg merged 3 commits intohaskell:masterfrom Aug 8, 2017
Merged
Allow async exceptions to pierce masked waitForProcess#101snoyberg merged 3 commits intohaskell:masterfrom
snoyberg merged 3 commits intohaskell:masterfrom
Conversation
Collaborator
|
This looks good, I feel much better about the usage of |
snoyberg
requested changes
Aug 3, 2017
| unless (e1 == ExitSuccess && e2 == ExitSuccess) | ||
| $ error "sleep exited with non-zero exit code!" | ||
|
|
||
| do |
Collaborator
There was a problem hiding this comment.
The test implementation is pretty fragile.
- The sleep value is low enough that the process could legitimately finish before the
waitForProcessbegins - I'd rather not rely on
BlockedIndefinitelyOnMVar, but instead useonExceptiontoputMVara value in the case of an exception - It's worth reporting the
ecin theRightcase; an exit code of 0 vs 127 will be highly informative, for instance
Contributor
Author
There was a problem hiding this comment.
Updated - how's that?
Collaborator
There was a problem hiding this comment.
Looks good! One last request: can you add a comment to the ChangeLog explaining the change in semantics here?
snoyberg
approved these changes
Aug 8, 2017
Collaborator
|
Thanks! |
Closed
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.
Hello!
I believe I found a bug in
waitForProcess. When run in theMaskedInterruptiblestate, an async exception doesn't actually bring the thread down.For example, the
typed-processlibrary exportswithProcesswhich is similar towithCreateProcess, but ends up callingwaitForProcessin the cleanup action of abracket.Even though
waitForProcessis aninterruptibleforeign call, I think what's happening is:waitForProcesscallinterruptibleforeign call, sendsSIGPIPE(GHC docs)c_waitForProcessreturns-1with errno =EINTRMaskedInterruptiblec_waitForProcessis retried because it's wrapped bythrowErrnoIfMinus1Retry_So our "interruptible"
waitForProcessis only half-interrupted :)My fix in this patch is to simply poll for any async exceptions before entering
c_waitForProcess. Here is some related discussion I had with @snoyberg.Thanks!