Stack overflow in withArgs leads to infinite memory-consuming loop
Given the program:
import System.Environment
main :: IO ()
main = do
putStrLn "Starting"
withArgs (replicate 1000 "") $ return ()
When run with:
ghc --make WithArgsBug.hs -rtsopts && WithArgsBug +RTS -K1K
The program prints out "Starting", then loops forever, taking 1 CPU core and allocating memory (approx 1Gb per min), until the computer is unresponsive. The program does not respond to Ctrl-C and has to be killed from the task manager.
The -K1K
flag limits the stack to approx 33Kb.
Trac metadata
Trac field | Value |
---|---|
Version | 8.4.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ndmitchell@gmail.com |
Operating system | |
Architecture |