Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shake cmd does not deal with async exceptions #538

Open
facundominguez opened this issue Oct 2, 2017 · 5 comments
Open

Shake cmd does not deal with async exceptions #538

facundominguez opened this issue Oct 2, 2017 · 5 comments

Comments

@facundominguez
Copy link

facundominguez commented Oct 2, 2017

The following program terminates when the action for a produces a failure, without waiting for action b to finish. Shouldn't shake wait until b completes?

$ cat test.hs
import Control.Concurrent
import Development.Shake
import System.Environment

main = withArgs ["-j"] $ shakeArgs shakeOptions $ do
    want ["a", "b"]
    "a" %> \_out -> do
      liftIO $ threadDelay (100 * 1000)
      fail "ugh"
    "b" %> \_out ->
      cmd Shell "sleep 3 && echo hello"

$ ghc-8.0.2 --make -threaded test.hs
[1 of 1] Compiling Main             ( test.hs, test.o )
Linking test ...
$ ./test
# sleep (for b)
Error when running Shake build system:
* a
ugh

$ hello
@ndmitchell
Copy link
Owner

When one action fails, Shake attempts to kill all the other actions that are underway, to return an error message to the user as fast as possible. From your trace, that seems to be what is happening - can you confirm?

@facundominguez
Copy link
Author

That's not what's happening. Shake seems to return immediately, and the action for b completes afterwards. Note that the hello message is printed after the new bash prompt is printed.

If the action for b were killed, the hello message would never print.

ndmitchell added a commit that referenced this issue Oct 14, 2017
@ndmitchell ndmitchell changed the title Shake does not wait for concurrent actions before finishing Shake cmd does not deal with async exceptions Oct 14, 2017
@ndmitchell
Copy link
Owner

Actually, it's caused by Shake not dealing with async exceptions properly in cmd - Shake does clean up (using async exceptions) and cmd incorrectly ignores them. I've found a nice test case and added it to the test suite, now to fix it's behaviour...

@ndmitchell
Copy link
Owner

Looking at the code, there's way too much try_, ignore, forkIO etc in the code. I don't know which one is causing the problem, but I'm tempted to remove most/all of them, and then see if the bug goes away - and in the process will probably also squash a lot of other bugs.

@ndmitchell
Copy link
Owner

I've fixed a bunch of stuff in Shake, but come down to underlying bugs in Process now: haskell/process#107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants