Opened 3 years ago

Closed 3 years ago

#5362 closed bug (fixed)

ghc: panic! mkUsageInfo: internal name? constr_a2Py{v}

Reported by: markwright Owned by: simonpj
Priority: highest Milestone: 7.2.1
Component: Template Haskell Version: 7.1
Keywords: panic mkUsageInfo Cc: slyfox@…
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Difficulty:
Test Case: th/T5362 Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo)

I apply this patch (also hopefully attached) to http://hackage.haskell.org/package/syb-with-class

--- syb-with-class-0.6.1.1-orig/syb-with-class.cabal	2010-11-16 19:41:26.000000000 +1100
+++ syb-with-class-0.6.1.1/syb-with-class.cabal	2011-07-31 01:44:18.356801182 +1000
@@ -25,7 +25,7 @@
   location: http://patch-tag.com/r/Saizan/syb-with-class/
 
 Library 
-    Build-Depends:      base >= 3 && < 5, template-haskell >= 2.4 && < 2.6, bytestring, array, containers
+    Build-Depends:      base >= 3 && < 5, template-haskell >= 2.4 && < 2.7, bytestring, array, containers
     Exposed-modules:
         Data.Generics.SYB.WithClass.Basics
         Data.Generics.SYB.WithClass.Context
--- syb-with-class-0.6.1.1-orig/Data/Generics/SYB/WithClass/Instances.hs	2010-11-16 19:41:26.000000000 +1100
+++ syb-with-class-0.6.1.1/Data/Generics/SYB/WithClass/Instances.hs	2011-07-31 01:44:38.367318167 +1000
@@ -724,4 +724,4 @@
 ------------------------------------------------------------------------------
 
 $( deriveData [''ByteString] )
-$( deriveData [''L.ByteString] )
+-- $( deriveData [''L.ByteString] )

ghc 7.2 rc1 encounters this compile time error:

runghc ./Setup.hs build
Building syb-with-class-0.6.1.1...
Preprocessing library syb-with-class-0.6.1.1...
[1 of 4] Compiling Data.Generics.SYB.WithClass.Context ( Data/Generics/SYB/WithClass/Context.hs, dist/build/Data/Generics/SYB/WithClass/Context.o )
[2 of 4] Compiling Data.Generics.SYB.WithClass.Basics ( Data/Generics/SYB/WithClass/Basics.hs, dist/build/Data/Generics/SYB/WithClass/Basics.o )
[3 of 4] Compiling Data.Generics.SYB.WithClass.Derive ( Data/Generics/SYB/WithClass/Derive.hs, dist/build/Data/Generics/SYB/WithClass/Derive.o )

Data/Generics/SYB/WithClass/Derive.hs:26:1:
    Warning: In the use of `mkTyCon'
             (imported from Data.Generics.SYB.WithClass.Basics, but defined in Data.Typeable):
             Deprecated: "either derive Typeable, or use mkTyCon3 instead"
[4 of 4] Compiling Data.Generics.SYB.WithClass.Instances ( Data/Generics/SYB/WithClass/Instances.hs, dist/build/Data/Generics/SYB/WithClass/Instances.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.3.0.3 ... linking ... done.
Loading package containers-0.4.1.0 ... linking ... done.
Loading package pretty-1.1.0.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package bytestring-0.9.2.0 ... linking ... done.
Loading package ffi-1.0 ... linking ... done.

Data/Generics/SYB/WithClass/Instances.hs:9:1:
    Warning: In the use of `mkTyCon'
             (imported from Data.Generics.SYB.WithClass.Basics, but defined in Data.Typeable):
             Deprecated: "either derive Typeable, or use mkTyCon3 instead"

Data/Generics/SYB/WithClass/Instances.hs:14:1:
    Warning: The import of `Data.ByteString.Lazy' is redundant
               except perhaps to import instances from `Data.ByteString.Lazy'
             To import instances alone, use: import Data.ByteString.Lazy()
ghc: panic! (the 'impossible' happened)
  (GHC version 7.2.0.20110728 for x86_64-unknown-linux):
	mkUsageInfo: internal name? constr_aaER{v}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug


Compilation exited abnormally with code 1 at Sun Jul 31 01:55:25

Attachments (1)

ghc_panic_mkUsageInfo_internal_name_constr_a2Py_v.patch (1005 bytes) - added by markwright 3 years ago.
patch to syb-with-class to reproduce ghc 7.2 rc1 panic

Download all attachments as: .zip

Change History (10)

Changed 3 years ago by markwright

patch to syb-with-class to reproduce ghc 7.2 rc1 panic

comment:1 Changed 3 years ago by slyfox

  • Cc slyfox@… added

comment:2 Changed 3 years ago by igloo

  • Description modified (diff)

comment:3 Changed 3 years ago by igloo

  • Component changed from Compiler to Template Haskell
  • Milestone set to 7.2.1
  • Priority changed from normal to highest

Thanks for the report.

Testcase:

{-# LANGUAGE TemplateHaskell #-}

module Foo where

import Language.Haskell.TH

$(
    do fName <- newName "f"
       gName <- newName "g"
       let gExp = varE gName

       sdf <- sigD fName [t| () |]
       sdg <- sigD gName [t| () |]
       fdf <- funD fName [clause [] (normalB [| undefined $gExp |]) []]
       fdg <- funD gName [clause [] (normalB [| undefined       |]) []]
       let ds = [sdf, fdf, sdg, fdg]
       runIO $ putStrLn $ pprint ds
       return ds
    )
$ ghc --make Foo.hs
[1 of 1] Compiling Foo              ( Foo.hs, Foo.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Loading package pretty-1.1.0.0 ... linking ... done.
Loading package array-0.3.0.3 ... linking ... done.
Loading package containers-0.4.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
f_0 :: GHC.Unit.()
f_0 = GHC.Err.undefined g_1
g_1 :: GHC.Unit.()
g_1 = GHC.Err.undefined

comment:4 Changed 3 years ago by simonpj

Ian in your test case, what is the problem. It compiles fine for me. no mkUsageInfo errors. Can you be more explicit about how to reproduce the error?

comment:5 Changed 3 years ago by igloo

Ah, sorry! I hadn't noticed, but my final change had worked around the bug. You need to have an export list:

{-# LANGUAGE TemplateHaskell #-}

module Foo () where

import Language.Haskell.TH

$(
    do fName <- newName "f"
       gName <- newName "g"
       let gExp = varE gName
       
       sdf <- sigD fName [t| () |]
       sdg <- sigD gName [t| () |]
       fdf <- funD fName [clause [] (normalB [| undefined $gExp |]) []]
       fdg <- funD gName [clause [] (normalB [| undefined       |]) []]
       let ds = [sdf, fdf, sdg, fdg]
       runIO $ putStrLn $ pprint ds
       return ds
    )
$ ghc --make q.hs
[1 of 1] Compiling Foo              ( q.hs, q.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Loading package pretty-1.1.0.0 ... linking ... done.
Loading package array-0.3.0.3 ... linking ... done.
Loading package containers-0.4.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
f_0 :: GHC.Unit.()
f_0 = GHC.Err.undefined g_1
g_1 :: GHC.Unit.()
g_1 = GHC.Err.undefined
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.2.0.20110728 for x86_64-unknown-linux):
        mkUsageInfo: internal name? g_aXE{v}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

comment:6 Changed 3 years ago by simonmar

  • Owner set to simonpj

comment:7 Changed 3 years ago by simonpj@…

commit bdf364e86560ddb25676c259a331b7fcd722d26d

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Tue Aug 2 14:06:12 2011 +0100

    Don't bleat about non-External names in mkUsageInfo
    
    See Note [Internal used_names].  Fixes Trac #5362.

 compiler/iface/MkIface.lhs |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

comment:8 Changed 3 years ago by simonpj

  • Status changed from new to merge
  • Test Case changed from http://hackage.haskell.org/package/syb-with-class to th/T5362

Thanks for reporting this. I think the above patch fixes it; at least, it certainly fixes Ian's test case, which I've added to the regression suite. Can you try your example?

comment:9 Changed 3 years ago by igloo

  • Resolution set to fixed
  • Status changed from merge to closed

Merged as changeset:f60cf3429acb4eeeda63b6183bb74f2552d0b47c

Please re-open if your example is still broken.

Note: See TracTickets for help on using tickets.