Skip to content

Recusive IO actions crash with segmentation fault

I am learning Haskell and wrote a program that writes some strings to stdout infinitely by recursing in an IO action. It seems such a simple construct crashes on FreeBSD when Ctrl+C is pressed to interrupt it.

I have been able to reduce it to a simple case like this:

main = do
        putStrLn "hello world"
        main

I compiled it with

ghc --make hello.hs

Ran it and then pressed Ctrl+C and immediately got:

[...]
hello world
hello world
hello world
hello world
^CSegmentation fault (core dumped)

Here is the backtrace of the crash:

(gdb) bt
#0  0x000000000047cdd7 in generic_handler ()
#1  0x000000080147c467 in swapcontext () from /lib/libthr.so.3
#2  0x000000080147c062 in sigaction () from /lib/libthr.so.3
#3  <signal handler called>
#4  0x00000008017d7b7a in select () from /lib/libc.so.7
#5  0x0000000801479b32 in select () from /lib/libthr.so.3
#6  0x000000000043cb13 in fdReady ()
#7  0x000000000044751c in base_GHCziIOziFD_zdwa3_info ()
#8  0x0000000000000000 in ?? ()

Operating system version is: FreeBSD 10.1-RELEASE-p5 (GENERIC)

Edited by nakal
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information