Skip to content

ghc has a stack space leak when prints warnings

Found on a crash when ghc tried to print a warning in a huge assembly file.

I've simplified it to autogenerated C file with an error:

# generate 10 million lines file
# and put an error into the very end of file
$ { for i in `seq 1 $((10 * 1000 * 1000))`; do echo "// a comment number $i"; done; echo 'static int foo = ;'; } > a.c
$ LANG=C powerpc64le-unknown-linux-gnu-ghc -c a.c +RTS -K128M

stack overflow: use +RTS -K<size> to increase it

C compiler tried to output something like the following to stderr:

a.c:10000001:0: error:
     error: expected expression before ';' token
     static int foo = ;

GHC finds 'a.c:10000001' location and tries to pretty-print the line. We get a space leak somewhere.

Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information