Forked thread running infinite loop blocks other threads from running
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.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.2.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |