[commit: ghc] ghc-7.8: Fix a rare parallel GC bug (29d8d32)

git at git.haskell.org git at git.haskell.org
Mon Oct 27 15:59:22 UTC 2014


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

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/29d8d320bb772e08246cf00e88d1970f7d6b26f3/ghc

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

commit 29d8d320bb772e08246cf00e88d1970f7d6b26f3
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Oct 23 11:12:16 2014 +0100

    Fix a rare parallel GC bug
    
    When there's a conflict between two threads evacuating the same TSO,
    in some cases we would update the incall->tso pointer to point to the
    wrong copy of the TSO.  This would get fixed during the next GC, but
    if the thread completed in the meantime, it would likely crash.  We're
    seeing this about once per day on a heavily loaded machine (it varies
    a lot though).
    
    (cherry picked from commit a11f71eff15ba2706cbb2ee29aaf7350909e0d2f)


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

29d8d320bb772e08246cf00e88d1970f7d6b26f3
 rts/sm/Scav.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c
index 5b1e5d0..1cc1482 100644
--- a/rts/sm/Scav.c
+++ b/rts/sm/Scav.c
@@ -55,7 +55,12 @@ scavengeTSO (StgTSO *tso)
 
     // update the pointer from the InCall.
     if (tso->bound != NULL) {
-        tso->bound->tso = tso;
+        // NB. We can't just set tso->bound->tso = tso, because this
+        // might be an invalid copy the TSO resulting from multiple
+        // threads evacuating the TSO simultaneously (see
+        // Evac.c:copy_tag()).  Calling evacuate() on this pointer
+        // will ensure that we update it to point to the correct copy.
+        evacuate((StgClosure **)&tso->bound->tso);
     }
 
     saved_eager = gct->eager_promotion;



More information about the ghc-commits mailing list