Segfault when reading lots of files
Given the program:
module Main(main) where
import Control.Monad
main :: IO ()
main = do
putStrLn "Starting segfault..."
xs <- replicateM 5000 $ do
src <- readFile "Main.hs"
src <- length src `seq` return (lines src)
return $ zipWith (++) src src
writeFile "out.txt" $ unlines $ concat xs
src <- readFile $ "out.txt"
length src `seq` return ()
putStrLn "Test complete, no segfault"
If I run GHC 7.0.1 on Windows, I see:
$ ghc --make Main.hs && main
[1 of 1] Compiling Main ( Main.hs, Main.o )
Linking Main.exe ...
Starting segfault...
Segmentation fault/access violation in generated code
The code segfaults about 50% of the time, slightly more if it has to build the program (since I guess that flushes stuff out of the disk cache, or slows down some operations). This bug has been boiled down from Hoogle, which hits it for real. I haven't been able to reproduce the bug on GHC 6.12.3, but the original bug occurred there too, so I suspect some variant of this bug also effects 6.12.3.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |