[GHC] #418: unsafeInterleaveIO + Ctrl-C/killThread related segfault

GHC trac at galois.com
Tue Jan 30 21:24:17 EST 2007


#418: unsafeInterleaveIO + Ctrl-C/killThread related segfault
----------------------------+-----------------------------------------------
 Reporter:  remit           |          Owner:  igloo  
     Type:  bug             |         Status:  new    
 Priority:  lowest          |      Milestone:  6.6.1  
Component:  Runtime System  |        Version:  6.4.1  
 Severity:  normal          |     Resolution:  None   
 Keywords:                  |     Difficulty:  Unknown
 Testcase:                  |   Architecture:  Unknown
       Os:  Unknown         |  
----------------------------+-----------------------------------------------
Changes (by igloo):

  * milestone:  => 6.6.1

Comment:

 Actually, I'm not so sure this is working properly after all, now.

 I'd expect this to manage to print () at some point even with the non-
 threaded RTS, but it doesn't:

 {{{
 module Main where

 import Control.Concurrent
 import System.IO.Unsafe (unsafeInterleaveIO)

 main = do
     v <- newEmptyMVar
     a <- unsafeInterleaveIO (readMVar v)
     t <- forkIO (print a)
     threadDelay (1000*1000)
     killThread t
     forkIO $ do putStrLn "W1"
                 print a
                 putStrLn "W2"
     putStrLn "Q1"
     putMVar v ()
     putStrLn "Q2"
     putMVar v ()
     putStrLn "Q3"
     threadDelay (1000*1000)
     putStrLn "Q4"
     isEmptyMVar v >>= print
     putStrLn "Q5"
     putMVar v ()
     putStrLn "Q6"
 }}}

 I get:

 {{{
 Q1W1
 Q2

 Q3
 Q4
 False
 Q5
 conc067: thread blocked indefinitely
 }}}

 (the "thread blocked indefinitely" I do expect).

 With the threaded RTS I get

 {{{
 Q1W1

 ()
 W2
 Q2
 conc067: thread blocked indefinitely
 }}}

 which also seems wrong as I expect to be able to get all the way to Q5.

 SimonM, what do you think?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/418>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list