diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2022-05-23 22:59:44 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-06-18 10:42:54 -0400 |
commit | 229d741f9907f0a07c475291fe3b1dbfcfea7aab (patch) | |
tree | 08af96d4b33c736ab3208ada7ebb8077dab69603 | |
parent | 9c575f24d41fed616e6f96fcbb4fa9a9687497a6 (diff) | |
download | haskell-229d741f9907f0a07c475291fe3b1dbfcfea7aab.tar.gz |
ghc-heap: Add (broken) test for #21622
-rw-r--r-- | libraries/ghc-heap/tests/T21622.hs | 25 | ||||
-rw-r--r-- | libraries/ghc-heap/tests/T21622.stdout | 1 | ||||
-rw-r--r-- | libraries/ghc-heap/tests/all.T | 3 |
3 files changed, 29 insertions, 0 deletions
diff --git a/libraries/ghc-heap/tests/T21622.hs b/libraries/ghc-heap/tests/T21622.hs new file mode 100644 index 0000000000..db53ad8722 --- /dev/null +++ b/libraries/ghc-heap/tests/T21622.hs @@ -0,0 +1,25 @@ +{-# OPTIONS_GHC -O0 #-} +{-# LANGUAGE MagicHash #-} + +import Control.Monad +import GHC.Exts.Heap +import System.Mem +import GHC.Exts +import GHC.Weak + +main :: IO () +main = do + let x = 42 :: Integer + Weak w <- mkWeak x () Nothing + weaks <- collectWeaks w + performMajorGC + print (x, fmap length weaks) + +collectWeaks :: Weak# v -> IO [Closure] +collectWeaks = \w -> getClosureData w >>= go [] + where + go :: [Closure] -> Closure -> IO [Closure] + go acc w@(WeakClosure {link}) + | next <- link = getBoxedClosureData next >>= go (w:acc) + | otherwise = return (w:acc) + diff --git a/libraries/ghc-heap/tests/T21622.stdout b/libraries/ghc-heap/tests/T21622.stdout new file mode 100644 index 0000000000..afb09db1ba --- /dev/null +++ b/libraries/ghc-heap/tests/T21622.stdout @@ -0,0 +1 @@ +(42,[4,5]) diff --git a/libraries/ghc-heap/tests/all.T b/libraries/ghc-heap/tests/all.T index fcafb9fa45..95a5426358 100644 --- a/libraries/ghc-heap/tests/all.T +++ b/libraries/ghc-heap/tests/all.T @@ -51,3 +51,6 @@ test('parse_tso_flags', ignore_stderr ], compile_and_run, ['']) +test('T21622', + [expect_broken(21622), only_ways(['normal'])], + compile_and_run, ['']) |