[Git][ghc/ghc][master] Fix crash in backpack signature merging with -ddump-rn-trace

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu May 25 00:59:32 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00
Fix crash in backpack signature merging with -ddump-rn-trace

In some cases, backpack signature merging could crash in addUsedGRE
when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause
unavailable interfaces to be loaded.
This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE
when -ddump-rn-trace is enabled.

Fixes #23424

Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>

- - - - -


4 changed files:

- compiler/GHC/Rename/Env.hs
- testsuite/driver/testlib.py
- + testsuite/tests/backpack/should_compile/T23424.bkp
- testsuite/tests/backpack/should_compile/all.T


Changes:

=====================================
compiler/GHC/Rename/Env.hs
=====================================
@@ -1742,7 +1742,8 @@ addUsedGRE warn_if_deprec gre
            DisableDeprecationWarnings -> return ()
        ; unless (isLocalGRE gre) $
          do { env <- getGblEnv
-            ; traceRn "addUsedGRE" (ppr gre)
+             -- Do not report the GREInfo (#23424)
+            ; traceRn "addUsedGRE" (ppr $ greName gre)
             ; updMutVar (tcg_used_gres env) (gre :) } }
 
 addUsedGREs :: [GlobalRdrElt] -> RnM ()
@@ -1752,7 +1753,9 @@ addUsedGREs :: [GlobalRdrElt] -> RnM ()
 addUsedGREs gres
   | null imp_gres = return ()
   | otherwise     = do { env <- getGblEnv
-                       ; traceRn "addUsedGREs" (ppr imp_gres)
+                        -- Do not report the GREInfo (#23424)
+                       ; traceRn "addUsedGREs"
+                             (ppr $ map greName imp_gres)
                        ; updMutVar (tcg_used_gres env) (imp_gres ++) }
   where
     imp_gres = filterOut isLocalGRE gres


=====================================
testsuite/driver/testlib.py
=====================================
@@ -2201,6 +2201,11 @@ async def compare_outputs(way: WayName,
                     normaliser: OutputNormalizer,
                     expected_file, actual_file, diff_file=None,
                     whitespace_normaliser: OutputNormalizer=lambda x:x) -> bool:
+    # Respect ignore_stdout and ignore_stderr options
+    if kind == 'stderr' and getTestOpts().ignore_stderr:
+        return True
+    if kind == 'stdout' and getTestOpts().ignore_stdout:
+        return True
 
     expected_path = in_srcdir(expected_file)
     actual_path = in_testdir(actual_file)


=====================================
testsuite/tests/backpack/should_compile/T23424.bkp
=====================================
@@ -0,0 +1,23 @@
+unit p where
+    signature A where
+        data T
+        x :: Bool
+    signature B where
+        import A
+        y :: T
+        z :: Bool
+unit q where
+    dependency signature p[A=<A>,B=<B>]
+    signature A (x) where
+    signature B (z) where
+    module M(y) where
+        import A
+        import B
+        y = x && z
+unit pimpl where
+    module A where
+        x = True
+    module B where
+        z = False
+unit r where
+    dependency q[A=pimpl:A,B=pimpl:B]


=====================================
testsuite/tests/backpack/should_compile/all.T
=====================================
@@ -60,3 +60,4 @@ test('T13214', normal, backpack_compile, [''])
 test('T13250', normal, backpack_compile, [''])
 test('T13323', normal, backpack_compile, [''])
 test('T20396', normal, backpack_compile, [''])
+test('T23424', [ignore_stdout, ignore_stderr], backpack_compile, ['-ddump-rn-trace -ddump-if-trace -ddump-tc-trace'])
\ No newline at end of file



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c0f2f9e37e625208a521fa5b7289b5fe37f94258
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/20230524/1d52a74a/attachment-0001.html>


More information about the ghc-commits mailing list