[commit: ghc] master: Fix a MSG_BLACKHOLE sanity check, add some comments (d90946c)

git at git.haskell.org git at git.haskell.org
Mon Sep 24 13:48:26 UTC 2018


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

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

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

commit d90946cea1357d3e99805c27dab1e811785a4088
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Mon Sep 24 16:21:27 2018 +0300

    Fix a MSG_BLACKHOLE sanity check, add some comments
    
    Reviewers: simonmar, bgamari, erikd
    
    Reviewed By: simonmar
    
    Subscribers: rwbarton, carter
    
    GHC Trac Issues: #15508
    
    Differential Revision: https://phabricator.haskell.org/D5178


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

d90946cea1357d3e99805c27dab1e811785a4088
 includes/rts/storage/Closures.h | 7 ++++++-
 rts/sm/Sanity.c                 | 8 ++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/includes/rts/storage/Closures.h b/includes/rts/storage/Closures.h
index 15231e0..7db67c7 100644
--- a/includes/rts/storage/Closures.h
+++ b/includes/rts/storage/Closures.h
@@ -130,10 +130,13 @@ typedef struct {
 
 typedef struct StgBlockingQueue_ {
     StgHeader   header;
-    struct StgBlockingQueue_ *link; // here so it looks like an IND
+    struct StgBlockingQueue_ *link;
+        // here so it looks like an IND, to be able to skip the queue without
+        // deleting it (done in wakeBlockingQueue())
     StgClosure *bh;  // the BLACKHOLE
     StgTSO     *owner;
     struct MessageBlackHole_ *queue;
+        // holds TSOs blocked on `bh`
 } StgBlockingQueue;
 
 typedef struct {
@@ -400,6 +403,8 @@ typedef struct MessageThrowTo_ {
 typedef struct MessageBlackHole_ {
     StgHeader   header;
     struct MessageBlackHole_ *link;
+        // here so it looks like an IND, to be able to skip the message without
+        // deleting it (done in throwToMsg())
     StgTSO     *tso;
     StgClosure *bh;
 } MessageBlackHole;
diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c
index 8d4171b..c6861f4 100644
--- a/rts/sm/Sanity.c
+++ b/rts/sm/Sanity.c
@@ -292,8 +292,12 @@ checkClosure( const StgClosure* p )
         ASSERT(LOOKS_LIKE_CLOSURE_PTR(bq->bh));
 
         ASSERT(get_itbl((StgClosure *)(bq->owner))->type == TSO);
-        ASSERT(bq->queue == (MessageBlackHole*)END_TSO_QUEUE
-               || bq->queue->header.info == &stg_MSG_BLACKHOLE_info);
+        ASSERT(// A bq with no other blocked TSOs:
+               bq->queue == (MessageBlackHole*)END_TSO_QUEUE ||
+               // A bq with blocked TSOs in its queue:
+               bq->queue->header.info == &stg_MSG_BLACKHOLE_info ||
+               // A bq with a deleted (in throwToMsg()) MSG_BLACKHOLE:
+               bq->queue->header.info == &stg_IND_info);
         ASSERT(bq->link == (StgBlockingQueue*)END_TSO_QUEUE ||
                get_itbl((StgClosure *)(bq->link))->type == IND ||
                get_itbl((StgClosure *)(bq->link))->type == BLOCKING_QUEUE);



More information about the ghc-commits mailing list