[GHC] #12221: GHC's signal handlers break C-c C-c force terminate

GHC ghc-devs at haskell.org
Wed Jun 22 17:40:01 UTC 2016


#12221: GHC's signal handlers break C-c C-c force terminate
-------------------------------------+-------------------------------------
           Reporter:  ezyang         |             Owner:  ezyang
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 GHC RTS has a policy that if it can't neatly shut off after the first C-c,
 it will forcibly terminate after the second one.

 This works all very well, until we reprogram the signal handler:

 {{{
 import Panic
 main = do
     installSignalHandlers
     let f x | x == 0 = 0 :: Int
             | otherwise = f (x + 1)
     print (f (1 :: Int))
 }}}

 Compile this with

 {{{
 ezyang at sabre:~$ ghc-8.0 --make M.hs -O -package ghc
 ezyang at sabre:~$ ./M
 ^C^C^C^C^C^C^C^C^Z
 [1]+  Stopped                 ./M
 ezyang at sabre:~$ kill -9 %1
 [1]+  Killed                  ./M
 }}}

 So yeah, that's a pain. What this means is that if GHC itself infinite
 loops, you can't ^C it.

 Maybe #10686 is exactly this, but my diagnosis doesn't seem to be
 consistent with their workaround in Leksah.  In particular, this program
 still does not accept C-C:

 {{{
 import Panic
 import System.Posix.Signals
        (emptySignalSet, sigINT, addSignal, unblockSignals)
 main = do
     installSignalHandlers
     unblockSignals $ addSignal sigINT emptySignalSet
     let f x | x == 0 = 0 :: Int
             | otherwise = f (x + 1)
     print (f (1 :: Int))
 }}}

 #4162 is people asking GHC to NOT install signal handlers unless we are
 running GHCi; this would also solve the problem.

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


More information about the ghc-tickets mailing list