[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: rts: avoid checking bdescr of value outside of Haskell heap

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Feb 29 02:19:31 UTC 2024



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
74b24a9b by Teo Camarasu at 2024-02-28T16:32:58+00:00
rts: avoid checking bdescr of value outside of Haskell heap

In nonmovingTidyWeaks we want to check if the key of a weak pointer
lives in the non-moving heap. We do this by checking the flags of the
block the key lives in. But we need to be careful with values that live
outside the Haskell heap, since they will lack a block descriptor and
looking for one may lead to a segfault. In this case we should just
accept that it isn't on the non-moving heap.

Resolves #24492

- - - - -
6bb7301d by Simon Peyton Jones at 2024-02-28T21:19:27-05:00
In mkDataConRep, ensure the in-scope set is right

A small change that fixes #24489

- - - - -


4 changed files:

- compiler/GHC/Types/Id/Make.hs
- rts/sm/NonMovingMark.c
- + testsuite/tests/deSugar/should_compile/T24489.hs
- testsuite/tests/deSugar/should_compile/all.T


Changes:

=====================================
compiler/GHC/Types/Id/Make.hs
=====================================
@@ -946,8 +946,7 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con
     mk_boxer boxers = DCB (\ ty_args src_vars ->
                       do { let (ex_vars, term_vars) = splitAtList ex_tvs src_vars
                                subst1 = zipTvSubst univ_tvs ty_args
-                               subst2 = extendTCvSubstList subst1 ex_tvs
-                                                           (mkTyCoVarTys ex_vars)
+                               subst2 = foldl2 extendTvSubstWithClone subst1 ex_tvs ex_vars
                          ; (rep_ids, binds) <- go subst2 boxers term_vars
                          ; return (ex_vars ++ rep_ids, binds) } )
 


=====================================
rts/sm/NonMovingMark.c
=====================================
@@ -2011,7 +2011,7 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue)
 
         // See Note [Weak pointer processing and the non-moving GC] in
         // MarkWeak.c
-        bool key_in_nonmoving = Bdescr((StgPtr) w->key)->flags & BF_NONMOVING;
+        bool key_in_nonmoving = HEAP_ALLOCED_GC(w->key) && Bdescr((StgPtr) w->key)->flags & BF_NONMOVING;
         if (!key_in_nonmoving || nonmovingIsNowAlive(w->key)) {
             nonmovingMarkLiveWeak(queue, w);
             did_work = true;


=====================================
testsuite/tests/deSugar/should_compile/T24489.hs
=====================================
@@ -0,0 +1,8 @@
+{-# LANGUAGE GADTs #-}
+module A where
+
+data Term where
+  BinaryTerm :: {-# UNPACK #-} !Bool -> tag -> Term
+
+f :: Term -> String
+f (BinaryTerm _ _) = "hello"


=====================================
testsuite/tests/deSugar/should_compile/all.T
=====================================
@@ -114,3 +114,4 @@ test('T19969', [grep_errmsg('LoopBreaker')], compile, ['-ddump-simpl -dsuppress-
 test('T19883', normal, compile, [''])
 test('T22719', normal, compile, ['-ddump-simpl -dsuppress-uniques -dno-typeable-binds'])
 test('T23550', normal, compile, [''])
+test('T24489', normal, compile, ['-O'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f98a1a53035d40e856452d27cb2ef101a2e03608...6bb7301d3f4a2ce64e1755ae878607bdf980e8ec

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f98a1a53035d40e856452d27cb2ef101a2e03608...6bb7301d3f4a2ce64e1755ae878607bdf980e8ec
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/20240228/b97e0ffb/attachment-0001.html>


More information about the ghc-commits mailing list