Skip to content

Regression in async exception handling (?) on Windows in network-2.6.3.4 #327

Description

@snoyberg

Sorry for the non-minimal repro, this is as far as I was able to take it for now. Consider the following Stack script, with uses LTS 10.7, which uses network-2.6.3.3.

#!/usr/bin/env stack
-- stack --resolver lts-10.7 script
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai.Handler.Warp

main :: IO ()
main = testWithApplication (pure undefined) $ \_ -> pure ()

As expected, this exits immediately. However, if you change this to LTS-10.8 (which uses network-2.6.3.4), it will hang indefinitely on Windows. This regression has caused the Yesod test suite to fail, see yesodweb/yesod#1523.

I'm only guessing that this is a change in asynchronous exception behavior based on looking at the diff between 2.6.3.3 and 2.6.3.4, it could be something else at play.

Activity

  1. afcady commented on Jun 19, 2018

    @afcady

    This is the same as #326? I think the problem is that withMVar is used in accept now, where it used to be readMVar. Then the same MVar gets used in Network.Socket.close. I'm having some difficulty finding the source since everything was moved around. But you can see in efb0e79 it's currentStatus <- readMVar status and in the version on hackage it's withMVar status

    Direct link to the line:

    currentStatus <- readMVar status

  2. afcady commented on Jun 19, 2018

    @afcady

    Here are the relevant lines:

    network/Network/Socket.hsc

    Lines 510 to 511 in cfa3f1f

    accept sock@(MkSocket s family stype protocol status) = do
    currentStatus <- readMVar status

    network/Network/Socket.hsc

    Lines 580 to 581 in aa49e91

    accept sock@(MkSocket s family stype protocol status) = withMVar status $ \currentStatus -> do

  3. eborden commented on Jun 24, 2018

    @eborden
    Collaborator

    Yeah the change was originally in 0375259, which was to fix finalizers being called in GHC 8.2.2. However we abandoned the finalizer work because its behaviour was problematic (#302).

    @afcady I would happily accept a PR to revert 0375259 and return to readMVar.

  4. kazu-yamamoto commented on Jun 25, 2018

    @kazu-yamamoto
    Collaborator

    withMVar was necessary for mkWeakMVar in GHC 8.2.2.
    But we have removed mkWeakMVar, so withMVar is not necessary anymore.
    OK.
    I will take care of this.

  5. kazu-yamamoto commented on Jun 25, 2018

    @kazu-yamamoto
    Collaborator

    @snoyberg @eborden Should we fix in 2.7 only? Or both in 2.6 and 2.7?

  6. snoyberg commented on Jun 25, 2018

    @snoyberg
    Author

    Given that a lot of packages haven't upgraded to 2.7 yet, it would be great to have this backported to 2.6.

  7. kazu-yamamoto commented on Jun 25, 2018

    @kazu-yamamoto
    Collaborator

    Just a question: Is it possible to release 2.6.x.y after 2.7.z.w is released in Hackage?

  8. snoyberg commented on Jun 25, 2018

    @snoyberg
    Author
  9. eborden commented on Jun 25, 2018

    @eborden
    Collaborator

    @kazu-yamamoto I'm going to put out the 2.6.x.x branch since many have not converted and this is a pretty sneaky insidious bug.

  10. kazu-yamamoto commented on Jun 26, 2018

    @kazu-yamamoto
    Collaborator

    I'm going to put out the 2.6.x.x branch since many have not converted and this is a pretty sneaky insidious bug.

    Thanks!

  11. eborden commented on Jul 7, 2018

    @eborden
    Collaborator

    This has been fixed in 2.6.3.6.

  12. eborden commented on Jul 7, 2018

    @eborden
    Collaborator

    Thanks @snoyberg and @afcady for hunting this one down!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions