[GHC] #10017: signal handlers are invoked multiple times when the threaded rts is used
GHC
ghc-devs at haskell.org
Sat Jan 24 13:40:34 UTC 2015
#10017: signal handlers are invoked multiple times when the threaded rts is used
-------------------------------------+-------------------------------------
Reporter: redneb | Owner: simonmar
Type: bug | Status: new
Priority: normal | Milestone:
Component: Runtime | Version: 7.10.1-rc1
System | Operating System: Linux
Keywords: | Type of failure: Incorrect result
Architecture: | at runtime
Unknown/Multiple | Blocked By:
Test Case: | Related Tickets: #9423
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
When you install a custom signal handler and the threaded rts is being
used, then the signal handler will be invoked multiple times. Here's a
program that the demonstrates this:
{{{#!hs
import Control.Concurrent
import System.Posix.Signals
main :: IO ()
main = do
_ <- flip (installHandler sig) Nothing $ Catch $
putStrLn $ "Received signal " ++ show sig
raiseSignal sig
threadDelay 100000
where
sig = sigUSR2
}}}
If you compile this with the `-threaded` flag and then run it with say
`+RTS -N4` then it produces the following output:
{{{
Received signal 12
Received signal 12
Received signal 12
Received signal 12
Received signal 12
}}}
In general the signal handler is invoked `n_capabilities+1` times. This
also happens with all other signals.
This regression was introduced by f9f89b7884ccc8ee5047cf4fffdf2b36df6832df
(which was later [changeset:4748f5936fe72d96edfa17b153dbfd84f2c4c053
reverted] but then [changeset:7e658bc14e2dd6baf208deebbdab9e1285ce4c72 re-
added]), a commit addressing #9423.
The cause of the problem is
[source:/rts/posix/Signals.c at f44bbc83bab62f9a2d25e69d87c2b4af25318d52#L256
this] loop. I don't understand why we need to write an event about the
signal received in the per capability control pipe introduced by the
aforementioned commit. Aren't these control pipes supposed only to be used
to shutdown the capabilities (which happens
[source:/rts/posix/Signals.c at f44bbc83bab62f9a2d25e69d87c2b4af25318d52#L183
here])?
Removing the loop seems to solve the issue, but I don't know if it makes
#9423 reappear. I cannot test this on a Mac OS X right now.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10017>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list