#5784: Forked thread running infinite loop blocks other threads from running
-----------------------------------------+----------------------------------
 Reporter:  joeyadams                    |          Owner:                
     Type:  bug                          |         Status:  new           
 Priority:  normal                       |      Component:  Runtime System
  Version:  7.2.2                        |       Keywords:                
       Os:  Linux                        |   Architecture:  x86_64 (amd64)
  Failure:  Incorrect result at runtime  |       Testcase:                
Blockedby:                               |       Blocking:                
  Related:                               |  
-----------------------------------------+----------------------------------
 When I compile the following under GHC 7.2.2 with -O1 or -O2, it spins in
 the forked thread's infinite loop.  The forked thread does not yield
 control to the main thread:

 {{{
 import Control.Concurrent
 import Control.Monad

 main :: IO ()
 main = do
     tid <- forkIO $ forever $ return ()
     putStrLn $ "Forked " ++ show tid
 }}}

 This happens up even if I compile with -threaded -rtsopts, use +RTS -N2,
 and use forkOS instead of forkIO.

 The problem goes away if I disable optimization.  It also goes away if I
 stick a yield :: IO () call in the loop.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to