Sending SIGINT to a program that uses forkOS may crash with various errors
This is the program:
module Main ( main ) where
import Control.Concurrent
import Control.Monad
main :: IO ()
main = recursive 0
where
recursive n = do
tid <- forkIO $ do
replicateM_ 100 $ forkOS $ return ()
replicateM_ (n `mod` 1000) yield
recursive (n+1)
I was trying to investigate a potential issue with leaking StablePtrs in forkOS but that's another story.
Compile with ghc Main.hs -prof -auto-all -threaded -o Main
. Run as ./Main +RTS -h
(I don't know if it's absolutely necessary to turn heap profiling on but I have more trouble getting these error messages without it).
Then, stop the program with SIGINT (by pressing CTRL+C or otherwise). The program sometimes crashes and produces one of the these two error messages:
Main: internal error: RELEASE_LOCK: I do not own this lock: rts/Task.c 242
(GHC version 7.10.1 for x86_64_unknown_linux)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Main: newBoundTask: RTS is not initialised; call hs_init() first
Sometimes the message may be slightly garbled (notice double internal error below):
Î: internal error: Main: internal error: RELEASE_LOCK: I do not own this lock: rts/Task.c 242
(GHC version 7.10.1 for x86_64_unknown_linux)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Replacing forkOS with forkIO seems to stop the messages. I can't reproduce this on FreeBSD. I'm using the downloaded binaries of 7.10.1 from GHC site on Arch Linux.
I used this simple bash script to see more of these messages because it won't crash reliably:
#!/bin/bash
while true; do
timeout -s INT 0.2 ./Main +RTS -h
done
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | low |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | simonmar |
Operating system | |
Architecture |