ghci crashes when running out of heap.
This may be the same as #1004 (closed), but the program is smaller (just running out of heap) and there's some more data points.
Running compiled code works fine (i.e., exits cleanly):
$ ghc -O2 Main.hs
$ ./a.out +RTS -M3M
Heap exhausted;
Current maximum heap size is 2998272 bytes (2 Mb);
use `+RTS -M<size>' to increase it.
running fully compiled code from ghci also exits cleanly:
$ ghci Main.hs +RTS -M5M
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main> main
Heap exhausted;
Current maximum heap size is 4997120 bytes (4 Mb);
use `+RTS -M<size>' to increase it.
but invoking compiled code from ghci gives various infelicitious results:
$ ghci Main.hs +RTS -M5M
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main> test 1000000
<interactive>: internal error: scavenge_mark_stack: unimplemented/strange closure type 3660 @ 0x1b1f0a4
(GHC version 6.6 for i386_apple_darwin)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
$ ghci Main.hs +RTS -M5M
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main> test 1000000
<interactive>: internal error: stg_ap_p_ret
(GHC version 6.6 for i386_apple_darwin)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
$ ghci Main.hs +RTS -M3M
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main> test 100000
Illegal instruction
$ ghci Main.hs +RTS -M4M
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main> test 1000000
Bus error
I think you get the idea.
The program is this:
module Main where
break2 p (x:xs) = if p x then
([],x:xs)
else
let (b1,b2) = break2 p xs
in (x : b1, b2)
break2 p [] = ([],[])
surprise xs = b1 ++ "\n surprise " ++ b2
where
(b1,b2) = break2 (=='\n') xs
test n = length $ surprise $ [head (show i) | i <-[1..n] ] ++ "\n the end"
main = print $ test 1000000
As an aside: I expected this program to run in constant space. AFAIK GHC evaluates "THUNK_SELECTORS" and thus eliminates the space leak in this infamous example [Hughes83][Wadler87][Sparud93] etc, but clearly this program is leaky!
Trac metadata
Trac field | Value |
---|---|
Version | 6.6 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |