[GHC] #5993: Segfault with threaded runtime and low +RTS -k

GHC cvs-ghc at haskell.org
Sun Apr 8 17:13:19 CEST 2012


#5993: Segfault with threaded runtime and low +RTS -k
---------------------------+------------------------------------------------
 Reporter:  ksf            |          Owner:                
     Type:  bug            |         Status:  new           
 Priority:  normal         |      Component:  Compiler      
  Version:  7.4.1          |       Keywords:                
       Os:  Linux          |   Architecture:  x86_64 (amd64)
  Failure:  Runtime crash  |       Testcase:                
Blockedby:                 |       Blocking:                
  Related:                 |  
---------------------------+------------------------------------------------
 Consider this minimal test case:

 {{{
 main = putStrLn "Hello, World!"
 }}}

 compile and run:

 {{{
 ghc -threaded hello.hs -rtsopts && ./hello +RTS -k8
 [1 of 1] Compiling Main             ( hello.hs, hello.o )
 Linking hello ...
 Hello, World!
 zsh: segmentation fault  ./hello +RTS -k8
 }}}

 And another one for the non-threaded runtime:

 {{{
 import Control.Concurrent
 main = do
     forkIO $ putStrLn "Hello, World!"
 }}}
 {{{
 ghc hello.hs -rtsopts && ./hello +RTS -k8
 [1 of 1] Compiling Main             ( hello.hs, hello.o )
 Linking hello ...
 Hello, World!
 zsh: segmentation fault  ./hello +RTS -k8
 }}}

 Do note that {{{ main = return () }}} works for the threaded runtime, and
 {{{ main = putStrLn "Hello, World!" }}} for the unthreaded.


 Now one could argue that -k is an insanely low setting, but I arrived
 there by tracking down BS.unpack mutating its underlying buffer (via
 unsafePackCStringFinalizer) in the first and last handfull of bytes into
 random, but replicable, junk, and trying to minimise the randomness of
 *when* that happens led me to the GC.

 ...which leads me to the hope that those two bugs are actually one and the
 same in different guises. The test case for the mutating behaviour is,
 alas, quite non-minimal.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5993>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list