Fix scavenge_stack crash (#9045)
[ghc.git] / testsuite / tests / rts / T9045.hs
1 -- This is nofib/smp/threads006. It fails in GHC 7.8.2 with a GC crash.
2
3 {-# OPTIONS_GHC -O2 #-}
4 import System.IO
5 import System.Environment
6 import System.CPUTime
7 import Text.Printf
8 import Control.Monad
9 import Control.Concurrent
10 import Control.Concurrent.MVar
11 import Control.Exception
12
13 main :: IO ()
14 main = do
15 hSetBuffering stdout NoBuffering
16 [nthreads] <- fmap (map read) getArgs
17 tids <- replicateM nthreads . mask $ \_ -> forkIO $ return ()
18 m <- newEmptyMVar
19 -- do it in a subthread to avoid bound-thread overhead
20 forkIO $ do mapM_ killThread tids; putMVar m ()
21 takeMVar m
22 return ()