[Haskell-cafe] How do I debug this RTS segfault?

Lana Black lanablack at amok.cc
Sun Jul 24 17:50:31 UTC 2016


Hello,

I have run into this RTS bug recently. In short, when executing multiple
consequtive forks, after 500-600 or so the process is terminated by
SIGSEGV. I know this kind of thing is totally artificial, but still.

The problem I have is that I can't get any meaningful backtrace in gdb.
For example, for threaded RTS I get this

(gdb) bt
#0  0x0000000000560d63 in
base_GHCziEventziThread_ensureIOManagerIsRunning1_info ()
Backtrace stopped: Cannot access memory at address 0x7fffff7fcea0

For non-threaded RTS I get this

(gdb) bt
#0  0x00000000007138c9 in stg_makeStablePtrzh ()
Backtrace stopped: Cannot access memory at address 0x7fffff7fc720

Build command: ghc --make -O2 -g -fforce-recomp fork.hs        
Add threaded if needed.

I was able to reproduce this bug with both GHC 7.10.3 and todays HEAD
with the code below.

>import System.Exit (exitSuccess)
>import System.Posix.Process (forkProcess)
>
>fork_ n | n > 0 = processPid =<< forkProcess (fork_ $! n - 1)
>        | otherwise = putStrLn "I'm done!"
>
>processPid pid | pid  > 0 = exitSuccess
>               | pid  < 0 = putStrLn "OOOPS, forkProcess failed!"
>               | otherwise = pure ()
>
>main = fork_ 1000
>

With best regards.


More information about the Haskell-Cafe mailing list