[commit: ghc] master: Fix a lost-wakeup bug in BLACKHOLE handling (#13751) (5984729)

git at git.haskell.org git at git.haskell.org
Thu Jun 8 07:38:22 UTC 2017


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

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

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

commit 598472908ebb08f6811b892f285490554c290ae3
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Sat Jun 3 20:26:13 2017 +0100

    Fix a lost-wakeup bug in BLACKHOLE handling (#13751)
    
    Summary:
    The problem occurred when
    * Threads A & B evaluate the same thunk
    * Thread A context-switches, so the thunk gets blackholed
    * Thread C enters the blackhole, creates a BLOCKING_QUEUE attached to
      the blackhole and thread A's `tso->bq` queue
    * Thread B updates the blackhole with a value, overwriting the BLOCKING_QUEUE
    * We GC, replacing A's update frame with stg_enter_checkbh
    * Throw an exception in A, which ignores the stg_enter_checkbh frame
    
    Now we have C blocked on A's tso->bq queue, but we forgot to check the
    queue because the stg_enter_checkbh frame has been thrown away by the
    exception.
    
    The solution and alternative designs are discussed in Note [upd-black-hole].
    
    This also exposed a bug in the interpreter, whereby we were sometimes
    context-switching without calling `threadPaused()`.  I've fixed this
    and added some Notes.
    
    Test Plan:
    * `cd testsuite/tests/concurrent && make slow`
    * validate
    
    Reviewers: niteria, bgamari, austin, erikd
    
    Reviewed By: erikd
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #13751
    
    Differential Revision: https://phabricator.haskell.org/D3630


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

598472908ebb08f6811b892f285490554c290ae3
 includes/stg/MiscClosures.h                 |  2 -
 rts/HeapStackCheck.cmm                      | 24 ----------
 rts/Interpreter.c                           | 10 +++++
 rts/Messages.c                              |  4 +-
 rts/Schedule.c                              |  7 ++-
 rts/StgStartup.cmm                          |  3 ++
 rts/sm/Evac.c                               | 64 +++++++++++++++++++++++++-
 rts/sm/Evac.h                               |  3 ++
 rts/sm/Scav.c                               | 70 +++++++++++++++++++----------
 testsuite/tests/concurrent/should_run/all.T |  1 +
 10 files changed, 133 insertions(+), 55 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 598472908ebb08f6811b892f285490554c290ae3


More information about the ghc-commits mailing list