diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-05-23 23:00:32 -0400 |
---|---|---|
committer | Douglas Wilson <douglas.wilson@gmail.com> | 2022-06-16 17:02:48 +0100 |
commit | 4d2db4a5547e88fb42ee74fa9d19566887ef4ac7 (patch) | |
tree | ccd53c2a1a90f5e3554532f15c4cb0c484342e8a /libraries/ghc-heap/GHC/Exts/Heap/Closures.hs | |
parent | 49837c7f0ccb2971823d297c0fa0aea0c47a0487 (diff) | |
download | haskell-wip/T21622.tar.gz |
ghc-heap: Don't Box NULL pointerswip/T21622
Previously we could construct a `Box` of a NULL pointer from the `link`
field of `StgWeak`. Now we take care to avoid ever introducing such
pointers in `collect_pointers` and ensure that the `link` field is
represented as a `Maybe` in the `Closure` type.
Fixes #21622
Diffstat (limited to 'libraries/ghc-heap/GHC/Exts/Heap/Closures.hs')
-rw-r--r-- | libraries/ghc-heap/GHC/Exts/Heap/Closures.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs b/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs index 075e2a5b17..13d1ff71c2 100644 --- a/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs +++ b/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs @@ -41,6 +41,7 @@ import GHC.Exts.Heap.InfoTableProf () import GHC.Exts.Heap.ProfInfo.Types import Data.Bits +import Data.Foldable (toList) import Data.Int import Data.Word import GHC.Exts @@ -228,8 +229,8 @@ data GenClosure b , mccPayload :: ![b] -- ^ Array payload } - -- | An @MVar#@, with a queue of thread state objects blocking on them - | MVarClosure + -- | An @MVar#@, with a queue of thread state objects blocking on them + | MVarClosure { info :: !StgInfoTable , queueHead :: !b -- ^ Pointer to head of queue , queueTail :: !b -- ^ Pointer to tail of queue @@ -265,7 +266,7 @@ data GenClosure b , key :: !b , value :: !b , finalizer :: !b - , link :: !b -- ^ next weak pointer for the capability, can be NULL. + , weakLink :: !(Maybe b) -- ^ next weak pointer for the capability } -- | Representation of StgTSO: A Thread State Object. The values for @@ -420,7 +421,7 @@ allClosures (MVarClosure {..}) = [queueHead,queueTail,value] allClosures (IOPortClosure {..}) = [queueHead,queueTail,value] allClosures (FunClosure {..}) = ptrArgs allClosures (BlockingQueueClosure {..}) = [link, blackHole, owner, queue] -allClosures (WeakClosure {..}) = [cfinalizers, key, value, finalizer, link] +allClosures (WeakClosure {..}) = [cfinalizers, key, value, finalizer] ++ Data.Foldable.toList weakLink allClosures (OtherClosure {..}) = hvalues allClosures _ = [] |