#4245: ghci panic: thread blocked indefinitely in an MVar operation
-------------------------------+--------------------------------------------
Reporter: pturnbull | Owner: igloo
Type: bug | Status: new
Priority: high | Milestone: 7.4.1
Component: GHCi | Version: 6.12.3
Keywords: MVar | Testcase:
Blockedby: | Difficulty:
Os: MacOS X | Blocking:
Architecture: x86_64 (amd64) | Failure: GHCi crash
-------------------------------+--------------------------------------------
Comment(by igloo):
With `z.hs`:
{{{
import Control.Concurrent
import Control.Exception
import Prelude hiding (catch)
import System.IO
main :: IO ()
main = do mv <- newEmptyMVar
tid <- forkIO $ otherThread mv
takeMVar mv
`catch` \e ->
do putStrLn ("Got exception: " ++ show (e :: SomeException))
putStrLn "Killing thread"
killThread tid
putStrLn "Killed thread"
otherThread :: MVar () -> IO ()
otherThread mv = do putStrLn "Waiting for input"
_ <- hWaitForInput stdin (-1)
putStrLn "There's some input"
putMVar mv ()
}}}
if we compile with HEAD on OS X (x86 or x86_64) with the threaded RTS:
{{{
ghc --make z -threaded
}}}
then run it, `^Z` it, `fg` it, then `^C` it, then the `killThread` blocks:
{{{
$ ./z
Waiting for input
^Z
[1]+ Stopped ./z
212:examples ian$ fg
./z
^CGot exception: user interrupt
Killing thread
}}}
Another `^C` silently terminates the program.
It doesn't happen if:
* We don't do the `^Z`/`fg`
* We don't use the threaded RTS
* It is run on Linux
So now the question is, why does it happen and how do we fix it?
(I believe Haskeline doing something like the above, mixed in with using
an MVar, is the underlying case of the GHCi bug)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4245#comment:19>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs