[commit: ghc] master: Blackholes can be large objects (#14497) (fb1f0a4)

git at git.haskell.org git at git.haskell.org
Mon Dec 18 16:24:38 UTC 2017


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

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

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

commit fb1f0a46983a887057de647eaaae9e83b5ebebd1
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Mon Dec 18 11:23:16 2017 -0500

    Blackholes can be large objects (#14497)
    
    Test Plan: validate
    
    Reviewers: bgamari, niteria, erikd, dfeuer
    
    Reviewed By: dfeuer
    
    Subscribers: Yuras, dfeuer, rwbarton, thomie, carter
    
    GHC Trac Issues: #14497
    
    Differential Revision: https://phabricator.haskell.org/D4254


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

fb1f0a46983a887057de647eaaae9e83b5ebebd1
 rts/sm/Evac.c                                               | 13 ++++++++++---
 testsuite/tests/rts/T14497.hs                               | 13 +++++++++++++
 .../IOError002.stdout => testsuite/tests/rts/T14497.stdout  |  0
 testsuite/tests/rts/all.T                                   |  1 +
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c
index fb1af0f..526f063 100644
--- a/rts/sm/Evac.c
+++ b/rts/sm/Evac.c
@@ -898,9 +898,16 @@ evacuate_BLACKHOLE(StgClosure **p)
 
     bd = Bdescr((P_)q);
 
-    // blackholes can't be in a compact, or large
-    ASSERT((bd->flags & (BF_COMPACT | BF_LARGE)) == 0);
-
+    // blackholes can't be in a compact
+    ASSERT((bd->flags & BF_COMPACT) == 0);
+
+    // blackholes *can* be in a large object: when raiseAsync() creates an
+    // AP_STACK the payload might be large enough to create a large object.
+    // See #14497.
+    if (bd->flags & BF_LARGE) {
+        evacuate_large((P_)q);
+        return;
+    }
     if (bd->flags & BF_EVACUATED) {
         if (bd->gen_no < gct->evac_gen_no) {
             gct->failed_to_evac = true;
diff --git a/testsuite/tests/rts/T14497.hs b/testsuite/tests/rts/T14497.hs
new file mode 100644
index 0000000..b6473f7
--- /dev/null
+++ b/testsuite/tests/rts/T14497.hs
@@ -0,0 +1,13 @@
+module Main (main) where
+
+import System.Timeout
+
+fuc :: Integer -> Integer
+fuc 0 = 1
+fuc n = n * fuc (n - 1)
+
+main :: IO ()
+main = do
+  let x = fuc 30000
+  timeout 1000 (print x)
+  print (x > 0)
diff --git a/libraries/base/tests/IO/IOError002.stdout b/testsuite/tests/rts/T14497.stdout
similarity index 100%
copy from libraries/base/tests/IO/IOError002.stdout
copy to testsuite/tests/rts/T14497.stdout
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index d5eaa76..7c5b9c7 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -381,3 +381,4 @@ test('T12497', [ unless(opsys('mingw32'), skip)
 test('T12903', [when(opsys('mingw32'), skip)], compile_and_run, [''])
 test('T13832', exit_code(1), compile_and_run, ['-threaded'])
 test('T13894', normal, compile_and_run, [''])
+test('T14497', normal, compile_and_run, ['-O'])



More information about the ghc-commits mailing list