Skip to content

Segfault when running with +RTS -N2

This program:

import Control.Concurrent
import Control.Concurrent.MVar
import Control.Exception
import System.IO

main :: IO ()
main = do hSetBuffering stdout NoBuffering
          let loop = doit >> loop
          loop

doit :: IO ()
doit = do v <- newMVar '.'
          t <- forkIO (foo v)
          threadDelay 1000
          killThread t
          takeMVar v >>= putChar

foo :: MVar Char -> IO ()
foo v = do let loop = do withMVar v $ \x -> evaluate x
                         loop
           loop

segfaults for me on amd64/Linux when compiled with a validated HEAD and run with +RTS -N2:

$ ghc --make j -threaded
[1 of 1] Compiling Main             ( j.hs, j.o )
Linking j ...
$ ./j +RTS -N2
zsh: segmentation fault  ./j +RTS -N2
$ ./j +RTS -N2
......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................zsh: segmentation fault  ./j +RTS -N2
$ ./j +RTS -N2
...........................................zsh: segmentation fault  ./j +RTS -N2
Trac metadata
Trac field Value
Version 6.11
Type Bug
TypeOfFailure OtherFailure
Priority high
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