[Git][ghc/ghc][wip/andreask/compacting_gc_crash] Compacting GC: Handle black holes in large objects.

Andreas Klebinger (@AndreasK) gitlab at gitlab.haskell.org
Sat Nov 23 10:30:57 UTC 2024



Andreas Klebinger pushed to branch wip/andreask/compacting_gc_crash at Glasgow Haskell Compiler / GHC


Commits:
6cee2272 by Andreas Klebinger at 2024-11-23T11:11:03+01:00
Compacting GC: Handle black holes in large objects.

As #14497 showed black holes can appear inside large objects when
we capture a computation and later blackhole it like we do for AP_STACK
closures.

Fixes #24791

- - - - -


5 changed files:

- rts/sm/Compact.c
- rts/sm/Evac.c
- + testsuite/tests/rts/T14497-compact.hs
- + testsuite/tests/rts/T14497-compact.stdout
- testsuite/tests/rts/all.T


Changes:

=====================================
rts/sm/Compact.c
=====================================
@@ -68,6 +68,10 @@
     pointer.
    ------------------------------------------------------------------------- */
 
+static /* STATIC_INLINE */ P_
+thread_obj (const StgInfoTable *info, P_ p);
+
+
 STATIC_INLINE W_
 UNTAG_PTR(W_ p)
 {
@@ -567,6 +571,13 @@ update_fwd_large( bdescr *bd )
       // nothing to follow
       continue;
 
+    // See Note [Black holes in large objects] in Evac.c for why.
+    case BLACKHOLE:
+      {
+        thread_obj(info, p);
+        continue;
+      }
+
     case MUT_ARR_PTRS_CLEAN:
     case MUT_ARR_PTRS_DIRTY:
     case MUT_ARR_PTRS_FROZEN_CLEAN:


=====================================
rts/sm/Evac.c
=====================================
@@ -1112,6 +1112,8 @@ evacuate_BLACKHOLE(StgClosure **p)
         return;
     }
 
+    // Note [Black holes in large objects]
+    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     // 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.


=====================================
testsuite/tests/rts/T14497-compact.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 500 (print x)
+  print (x > 0)


=====================================
testsuite/tests/rts/T14497-compact.stdout
=====================================
@@ -0,0 +1 @@
+True


=====================================
testsuite/tests/rts/all.T
=====================================
@@ -444,6 +444,13 @@ test('T13894', js_skip, compile_and_run, [''])
 # this test fails with the profasm way on some machines but not others,
 # so we just skip it.
 test('T14497', [omit_ways(['profasm']), multi_cpu_race], compile_and_run, ['-O'])
+# The issue in the above test also happened with compaction enabled.
+test('T14497-compact',
+               [ extra_files(['T14497.hs'])
+               , omit_ways(['profasm'])
+               , multi_cpu_race
+               , extra_run_opts('+RTS -c -RTS')
+               ] , compile_and_run, ['-O'])
 test('T14695', [js_broken(22359), ignore_stderr], makefile_test, ['T14695'])
 test('T14702', [ ignore_stdout
                , when(unregisterised(), skip)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6cee2272f75edcd85cb950e98d1d390964f17add

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6cee2272f75edcd85cb950e98d1d390964f17add
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241123/7994faf4/attachment-0001.html>


More information about the ghc-commits mailing list