From 92c93544939199f6ef758e1658149a971d4437c9 Mon Sep 17 00:00:00 2001 From: Andreas Voellmy Date: Mon, 2 Feb 2015 10:50:52 -0500 Subject: Fix #10017 Summary: In the threaded RTS, a signal is delivered from the RTS to Haskell user code by writing to file that one of the IO managers watches (via an instance of GHC.Event.Control.Control). When the IO manager receives the signal, it calls GHC.Conc.Signal.runHandlers to invoke Haskell signal handler. In the move from a single IO manager to one IO manager per capability, the behavior was (wrongly) extended so that a signal is delivered to every event manager (see #9423), each of which invoke Haskell signal handlers, leading to multiple invocations of Haskell signal handlers for a single signal. This change fixes this problem by having the RTS (in generic_handler()) notify only the Control instance used by the TimerManager, rather than all the per-capability IO managers. Reviewers: austin, hvr, simonmar, Mikolaj Reviewed By: simonmar, Mikolaj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D641 --- testsuite/tests/rts/T10017.hs | 11 +++++++++++ testsuite/tests/rts/T10017.stdout | 1 + testsuite/tests/rts/all.T | 2 ++ 3 files changed, 14 insertions(+) create mode 100644 testsuite/tests/rts/T10017.hs create mode 100644 testsuite/tests/rts/T10017.stdout (limited to 'testsuite/tests/rts') diff --git a/testsuite/tests/rts/T10017.hs b/testsuite/tests/rts/T10017.hs new file mode 100644 index 0000000000..ed34841abb --- /dev/null +++ b/testsuite/tests/rts/T10017.hs @@ -0,0 +1,11 @@ +import Control.Concurrent +import System.Posix.Signals + +main :: IO () +main = do + _ <- flip (installHandler sig) Nothing $ Catch $ + putStrLn $ "Received my signal" + raiseSignal sig + threadDelay 100000 + where + sig = sigUSR2 diff --git a/testsuite/tests/rts/T10017.stdout b/testsuite/tests/rts/T10017.stdout new file mode 100644 index 0000000000..f138924616 --- /dev/null +++ b/testsuite/tests/rts/T10017.stdout @@ -0,0 +1 @@ +Received my signal diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index 89f1da81d5..88c354f2f5 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -238,6 +238,8 @@ test('T9045', [ omit_ways(['ghci']), extra_run_opts('10000 +RTS -A8k -RTS') ], c # with the non-threaded one. test('T9078', [ omit_ways(threaded_ways) ], compile_and_run, ['-with-rtsopts="-DS" -debug']) +test('T10017', [ only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, ['']) + test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip) # this needs runtime infrastructure to do in ghci: # '-rdynamic' ghc, load modules only via dlopen(RTLD_BLOBAL) and more. -- cgit v1.2.1