Skip to content

Shake cmd does not deal with async exceptions #538

Open

Description

@facundominguez

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

Activity

  1. ndmitchell commented on Oct 2, 2017

    @ndmitchell
    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?

  2. facundominguez commented on Oct 3, 2017

    @facundominguez
    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.

  3. added a commit that references this issue on Oct 14, 2017
  4. changed the title [-]Shake does not wait for concurrent actions before finishing[/-] [+]Shake cmd does not deal with async exceptions[/+] on Oct 14, 2017
  5. ndmitchell commented on Oct 14, 2017

    @ndmitchell
    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...

  6. ndmitchell commented on Oct 14, 2017

    @ndmitchell
    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.

  7. added 3 commits that reference this issue on Oct 16, 2017
  8. ndmitchell commented on Nov 6, 2017

    @ndmitchell
    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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions