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

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

Closed
snoyberg opened this issue Jun 19, 2018 · 12 comments
Closed
Assignees

Comments

@snoyberg
Copy link

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.

@afcady
Copy link

afcady commented Jun 19, 2018

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

@afcady
Copy link

afcady commented Jun 19, 2018

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

@eborden
Copy link
Collaborator

eborden commented Jun 24, 2018

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.

@kazu-yamamoto
Copy link
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.

@kazu-yamamoto kazu-yamamoto self-assigned this Jun 25, 2018
@kazu-yamamoto
Copy link
Collaborator

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

@snoyberg
Copy link
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.

kazu-yamamoto added a commit to kazu-yamamoto/network that referenced this issue Jun 25, 2018
mkWeakMVar is not used anymore. So, this code is not necessary.
@kazu-yamamoto
Copy link
Collaborator

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

@snoyberg
Copy link
Author

snoyberg commented Jun 25, 2018 via email

This was referenced Jun 25, 2018
eborden pushed a commit that referenced this issue Jun 25, 2018
mkWeakMVar is not used anymore. So, this code is not necessary.
eborden pushed a commit that referenced this issue Jun 25, 2018
mkWeakMVar is not used anymore. So, this code is not necessary.
@eborden
Copy link
Collaborator

eborden commented Jun 25, 2018

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

@kazu-yamamoto
Copy link
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!

@eborden
Copy link
Collaborator

eborden commented Jul 7, 2018

This has been fixed in 2.6.3.6.

@eborden eborden closed this as completed Jul 7, 2018
@eborden
Copy link
Collaborator

eborden commented Jul 7, 2018

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants