[commit: ghc] master: rts/base: Fix #9423 (f9f89b7)

git at git.haskell.org git at git.haskell.org
Tue Aug 19 13:03:57 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/f9f89b7884ccc8ee5047cf4fffdf2b36df6832df/ghc

>---------------------------------------------------------------

commit f9f89b7884ccc8ee5047cf4fffdf2b36df6832df
Author: Andreas Voellmy <andreas.voellmy at gmail.com>
Date:   Tue Aug 19 08:02:18 2014 -0500

    rts/base: Fix #9423
    
    Summary:
    Fix #9423.
    
    The problem in #9423 is caused when code invoked by `hs_exit()` waits
    on all foreign calls to return, but some IO managers are in `safe` foreign
    calls and do not return. The previous design signaled to the timer manager
    (via its control pipe) that it should "die" and when the timer manager
    returned to Haskell-land, the Haskell code in timer manager then signalled
    to the IO manager threads that they should return from foreign calls and
    `die`. Unfortunately, in the shutdown sequence the timer manager is unable
    to return to Haskell-land fast enough and so the code that signals to the
    IO manager threads (via their control pipes) is never executed and the IO
    manager threads remain out in the foreign calls.
    
    This patch solves this problem by having the RTS signal to all the IO
    manager threads (via their control pipes; and in addition to signalling
    to the timer manager thread) that they should shutdown (in `ioManagerDie()`
    in `rts/Signals.c`. To do this, we arrange for each IO manager thread to
    register its control pipe with the RTS (in `GHC.Thread.startIOManagerThread`).
    In addition, `GHC.Thread.startTimerManagerThread` registers its control pipe.
    These are registered via C functions `setTimerManagerControlFd` (in
    `rts/Signals.c`) and `setIOManagerControlFd` (in `rts/Capability.c`). The IO
    manager control pipe file descriptors are stored in a new field of the
    `Capability_ struct`.
    
    Test Plan: See the notes on #9423 to recreate the problem and to verify that it no longer occurs with the fix.
    
    Auditors: simonmar
    
    Reviewers: simonmar, edsko, ezyang, austin
    
    Reviewed By: austin
    
    Subscribers: phaskell, simonmar, ezyang, carter, relrod
    
    Differential Revision: https://phabricator.haskell.org/D129
    
    GHC Trac Issues: #9423, #9284


>---------------------------------------------------------------

f9f89b7884ccc8ee5047cf4fffdf2b36df6832df
 includes/rts/IOManager.h                 |  3 +-
 libraries/base/GHC/Event/Control.hs      |  8 +---
 libraries/base/GHC/Event/Manager.hs      |  1 +
 libraries/base/GHC/Event/Thread.hs       | 35 ++++++++------
 libraries/base/GHC/Event/TimerManager.hs |  1 +
 rts/Capability.c                         | 11 +++++
 rts/Capability.h                         |  3 ++
 rts/Linker.c                             |  1 +
 rts/posix/Signals.c                      | 80 ++++++++++++++++++++------------
 9 files changed, 92 insertions(+), 51 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc f9f89b7884ccc8ee5047cf4fffdf2b36df6832df


More information about the ghc-commits mailing list