[GHC] #10199: Sending SIGINT to a program that uses forkOS may crash with various errors

#10199: Sending SIGINT to a program that uses forkOS may crash with various errors -------------------------------------+------------------------------------- Reporter: adeon | Owner: simonmar Type: bug | Status: new Priority: low | Milestone: Component: Runtime | Version: 7.10.1 System | Operating System: Linux Keywords: | Type of failure: Runtime crash Architecture: x86_64 | Blocked By: (amd64) | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- This is the program: {{{#!hs 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: {{{#!bash #!/bin/bash while true; do timeout -s INT 0.2 ./Main +RTS -h done }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10199 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10199: Sending SIGINT to a program that uses forkOS may crash with various errors -------------------------------------+------------------------------------- Reporter: adeon | Owner: simonmar Type: bug | Status: new Priority: low | Milestone: Component: Runtime System | Version: 7.10.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Runtime crash | (amd64) Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonmar): Yes, what happens here is that the RTS shuts down while one of the forkOS calls is just about to call back into Haskell to create the bound thread. The effect is similar to calling a foreign exported function before calling `hs_init()` - that's where the `newBoundTask` message comes from. Depending on the timing, we might have got past the `newBoundTask` check when the RTS shuts down. We should close that race condition. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10199#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC