[GHC] #9032: Panic with self-import

#9032: Panic with self-import -----------------------------------+--------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time crash Unknown/Multiple | Test Case: Difficulty: Unknown | Blocking: Blocked By: | Related Tickets: | -----------------------------------+--------------------------------------- I've run into GHC panic with this code: {{{ {-# OPTIONS_GHC -fno-warn-unused-imports #-} module Singletons.Star where import Data.Singletons.Prelude import Data.Singletons.Decide import Data.Singletons.CustomStar import Singletons.Nat import Singletons.Star -- <------- HERE data Vec :: * -> Nat -> * where VNil :: Vec a Zero VCons :: a -> Vec a n -> Vec a (Succ n) $(singletonStar [''Nat, ''Int, ''String, ''Maybe, ''Vec]) }}} This is a test in `singletons` package that leads to a panic when run: {{{ ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): tcIfaceGlobal (local): not found: singletons-1.0:Singletons.Star.TFCo:R:DemoteRep*KProxy{tc r0} [] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} I was unable to minimize the test case. Reproducing requires following steps: 1. Installing latest th-desugar library from github: {{{ git clone https://github.com/goldfirere/th-desugar.git cd th-desugar cabal install }}} 2. Getting latest development version of singletons: {{{ git clone https://github.com/goldfirere/singletons cd singletons git checkout 56734c2bda721cb9a6a3021b901e3b29d6564f0c make tests }}} All should go well. Now you need to edit file `tests/compile-and- dump/Singletons/Star.hs` and uncomment `import Singletons.Star` line. It should be possible to reproduce the bug with: {{{ cd tests/compile-and-dump/ghc -package-name singletons-1.0 Singletons/Star.hs -i../../dist/build -c -XTemplateHaskell }}} It's important to run `make tests` first so that all interface files required by `Star.hs` are in place. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import ---------------------------------------+----------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- Comment (by monoidal): Here's a test case with no external dependencies, obtained from singletons and th-desugar; crashes 7.8.2 and HEAD. Put two files CustomStar.hs {{{ {-# LANGUAGE TypeFamilies, KindSignatures, TemplateHaskell #-} module CustomStar ( singletonStar ) where import Language.Haskell.TH import Language.Haskell.TH.Syntax ( Quasi(..) ) data family Sing a singFamilyName :: Name singFamilyName = ''Sing singletonStar :: Quasi q => q [Dec] singletonStar = do aName <- qNewName "z" return $ [DataInstD [] singFamilyName [SigT (VarT aName) StarT] [] []] }}} Star.hs {{{ {-# LANGUAGE CPP, TemplateHaskell, TypeFamilies #-} module Star where import CustomStar #ifdef ERR import Star #endif $(singletonStar) }}} and execute {{{ rm -f *.dyn_hi *.dyn_o *.hi *.o ghc CustomStar.hs ghc -c Star.hs ghc -c Star.hs -DERR }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Compile- | Blocked By: time crash | Related Tickets: #1012 Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by jstolarek): * related: => #1012 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Template | Version: 7.8.2 Haskell | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: #1012 time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * component: Compiler => Template Haskell * milestone: => 7.10.1 Old description:
I've run into GHC panic with this code:
{{{ {-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Singletons.Star where
import Data.Singletons.Prelude import Data.Singletons.Decide import Data.Singletons.CustomStar import Singletons.Nat import Singletons.Star -- <------- HERE
data Vec :: * -> Nat -> * where VNil :: Vec a Zero VCons :: a -> Vec a n -> Vec a (Succ n)
$(singletonStar [''Nat, ''Int, ''String, ''Maybe, ''Vec]) }}}
This is a test in `singletons` package that leads to a panic when run:
{{{ ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): tcIfaceGlobal (local): not found: singletons-1.0:Singletons.Star.TFCo:R:DemoteRep*KProxy{tc r0} []
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}}
I was unable to minimize the test case. Reproducing requires following steps:
1. Installing latest th-desugar library from github:
{{{ git clone https://github.com/goldfirere/th-desugar.git cd th-desugar cabal install }}}
2. Getting latest development version of singletons:
{{{ git clone https://github.com/goldfirere/singletons cd singletons git checkout 56734c2bda721cb9a6a3021b901e3b29d6564f0c make tests }}}
All should go well. Now you need to edit file `tests/compile-and- dump/Singletons/Star.hs` and uncomment `import Singletons.Star` line. It should be possible to reproduce the bug with:
{{{ cd tests/compile-and-dump/ghc -package-name singletons-1.0 Singletons/Star.hs -i../../dist/build -c -XTemplateHaskell }}}
It's important to run `make tests` first so that all interface files required by `Star.hs` are in place.
New description: A test in the `singletons` package leads to a panic when run: {{{ ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): tcIfaceGlobal (local): not found: singletons-1.0:Singletons.Star.TFCo:R:DemoteRep*KProxy{tc r0} [] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Edit: see comment:1 for a testcase. -- Comment: Still present in 7.9. I have cleaned up the description a bit. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Template | Version: 7.8.2 Haskell | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: #1012 time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * priority: normal => highest Comment: I think a module should simply never import itself. I propose to make this an error. Does anyone object? I'm increasing the priority to highest to make sure that we attend to this, not because it's terribly important. It's very easy to implement if we agree that it should be illegal. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Template | Version: 7.8.2 Haskell | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: #1012 time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by monoidal): It's already an error (`Module imports form a cycle: module 'X' imports itself`), but in this case the self-import somehow gives a panic. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Template | Version: 7.8.2 Haskell | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: #1012 time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Replying to [comment:5 monoidal]:
It's already an error (`Module imports form a cycle: module 'X' imports itself`), but in this case the self-import somehow gives a panic.
Good point. So it's already an error; albeit one that is only reported with `--make`. We should get a decent error in one-shot mode too. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 7.10.1
Component: Template | Version: 7.8.2
Haskell | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: Compile- | Related Tickets: #1012
time crash |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#9032: Panic with self-import -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: closed Priority: highest | Milestone: 7.10.1 Component: Template | Version: 7.8.2 Haskell | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: #1012 time crash | Test Case: | rename/should_fail/T9032 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => rename/should_fail/T9032 * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9032: Panic with self-import -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: merge Priority: highest | Milestone: 7.10.1 Component: Template | Version: 7.8.2 Haskell | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: #1012 time crash | Test Case: | rename/should_fail/T9032 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by hvr): * status: closed => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9032#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC