Segfault with threaded runtime and low +RTS -k
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.
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |