[GHC] #14503: Killing a thread will block if there is another process reading from a handle
GHC
ghc-devs at haskell.org
Mon Nov 27 09:07:11 UTC 2017
#14503: Killing a thread will block if there is another process reading from a
handle
-------------------------------------+-------------------------------------
Reporter: dnadales | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 8.0.2
Resolution: | Keywords:
Operating System: Windows | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by dnadales):
* component: Compiler => libraries/base
Comment:
The problem can be easily reproduced by running these two programs in
parallel:
{{{#!hs
readWithinNSecs :: IO ()
readWithinNSecs = withSocketsDo $ do
h <- connectTo "localhost" (PortNumber 9090)
hSetBuffering h NoBuffering
readerTid <- forkIO $ reader h
threadDelay $ 2 * 10^6
putStrLn "Killing the reader"
killThread readerTid
putStrLn "Reader thread killed"
where
reader h = do
line <- strip <$> hGetLine h
putStrLn $ "Got " ++ line
}}}
{{{#!java
import java.net.*;
import java.io.*;
public class Reader {
public static void main(String[] args) throws IOException,
InterruptedException {
ServerSocket serverSock = new ServerSocket(9090);
Socket sock = serverSock.accept();
InputStream inStream = sock.getInputStream();
BufferedReader sockIn = new BufferedReader(new
InputStreamReader(inStream));
while (true) {
Thread.sleep(1000);
System.out.println("Trying to read something...");
String s = sockIn.readLine();
System.out.println("Got " + s );
}
}
}
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14503#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list