[GHC] #10182: lookupIfaceGlobal crash with SOURCE import

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Try this (in `testsuite/tests/stranal/should_compile`) {{{ bash$ ghc -c T8743.hs-boot bash$ ghc -c T8743.hs ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): tcIfaceGlobal (local): not found: main:T8743.$fxToRowMaybe{v r2J} [(r2L, Class ‘main:T8743.ToRow{tc r2L}’), (r2M, Data constructor ‘main:T8743.D:ToRow{d r2M}’), (r2P, Identifier ‘main:T8743.D:ToRow{v r2P}’), (roB, Identifier ‘main:T8743.toRow{v roB}’), (rqT, Coercion axiom ‘main:T8743.NTCo:ToRow{tc rqT}’)] }}} Something clearly wrong here. It think this happens with prettty much any version of GHC. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Description changed by simonpj: Old description:
Try this (in `testsuite/tests/stranal/should_compile`) {{{ bash$ ghc -c T8743.hs-boot bash$ ghc -c T8743.hs ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): tcIfaceGlobal (local): not found: main:T8743.$fxToRowMaybe{v r2J} [(r2L, Class ‘main:T8743.ToRow{tc r2L}’), (r2M, Data constructor ‘main:T8743.D:ToRow{d r2M}’), (r2P, Identifier ‘main:T8743.D:ToRow{v r2P}’), (roB, Identifier ‘main:T8743.toRow{v roB}’), (rqT, Coercion axiom ‘main:T8743.NTCo:ToRow{tc rqT}’)] }}} Something clearly wrong here. It think this happens with prettty much any version of GHC.
New description: Try this (in `testsuite/tests/stranal/should_compile`) {{{ bash$ ghc -c T8743.hs-boot bash$ ghc -c T8743.hs ghc: panic! (the 'impossible' happened) (GHC version 7.8.2 for x86_64-unknown-linux): tcIfaceGlobal (local): not found: main:T8743.$fxToRowMaybe{v r2J} [(r2L, Class ‘main:T8743.ToRow{tc r2L}’), (r2M, Data constructor ‘main:T8743.D:ToRow{d r2M}’), (r2P, Identifier ‘main:T8743.D:ToRow{v r2P}’), (roB, Identifier ‘main:T8743.toRow{v roB}’), (rqT, Coercion axiom ‘main:T8743.NTCo:ToRow{tc rqT}’)] }}} Something clearly wrong here. It think this happens with prettty much any version of GHC. I found this when poking about in #10181. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.12.1
Component: Compiler | Version: 7.8.4
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Joachim Breitner

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by ezyang): (Note: it has to be a self boot-import; indirecting it through another module eliminates the error.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by ezyang): I can reproduce with an even more minimized test-case, on a stage 2 quick build: {{{ module T8743 where class ToRow a instance ToRow () }}} {{{ module T8743 where import {-# SOURCE #-} T8743 () class ToRow a instance ToRow () where }}} With some more tracing you can get a clue: `tcIfaceGlobal` is being called because GHC is trying to report a duplicate instance error. That certainly should not happen! So in one-shot compilation, GHC is seeing an instance in its environment that is NOT supposed to be there. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by ezyang): Here is what's going on: when a self-import occurs, the hi-boot for the current module is being loaded into the EPS by `loadInterface`. **This should never happen.** However, in the absence of type class instances, this is relatively harmless, as we won't actually look in the EPS to find names for locally defined identifiers. However, there is one case where we always consult the EPS: instance lookup! An orphan instance also causes an EPS-updating load of the hi-boot, even absent a direct import, as the boot file will be recorded as an orphan and thus we'll try to load it. One thing that is a bit tiresome is that on a direct `{-# SOURCE #-}` import, we really do need to read in the boot interface (just not add it to the EPS), since we might be some identifiers in another namespace: {{{ -- A.hs-boot module A(Bool) where -- A.hs module A(Bool) where import {-# SOURCE #-} qualified A as A2 data X = X A2.Bool }}} But this has never actually worked with declarations in the hs-boot itself, see #7672. (I spent some time being confused at the interface trace, which claimed `Reading [boot] interface for T8743` even in non buggy cases. This is because we always load the `hi-boot` interface to compare against the "Real Thing"; however, THIS goes through `tcHiBootIface`, which DOES NOT update the EPS.) I suspect simonpj's original test case was not fully reduced due to #10333. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: ezyang Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonpj): * owner: => ezyang Comment: We agreed to fix this by make a self SOURCE import simply an error. (With a Note in the code to explain why it's awkward to allow it.) Edward will do this. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: | https://phabricator.haskell.org/D860 -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => patch * differential: => https://phabricator.haskell.org/D860 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: | https://phabricator.haskell.org/D860 -------------------------------------+------------------------------------- Comment (by ezyang): Patch doesn't validate; there are about 11 test-cases that use a self boot import to tickle the hs-boot mechanism. I'm converting them to have an intermediate module (bleh!) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: | https://phabricator.haskell.org/D860 -------------------------------------+------------------------------------- Comment (by nomeata): With Edwards’s change to the test case to not do a self-SOURCE-import, but rather indirected through another module, we get: {{{ *** Core Lint errors : in result of Simplifier *** T8743.hs-boot:3:10: warning: [RHS of $fxToRowMaybe :: forall a_anp. ToRow (Maybe a_anp)] idArity 1 exceeds typeArity 0: $fxToRowMaybe }}} The error message is misleading: It occurs when compiling `T8743.hs` proper. The desugared code before optimization is fine, after it occurs. My guess is that still from compiling `T8740.hs-boot`, GHC has `ToRow` in its environment as an abstract data type, without the information that it is just a newtype around `a -> [()]`. This is used by the renamer when parsing `T8740.hs`, so `typeArity`, which looks at the `DataTypCon`, returns `0` instead of `1`. Rough guess: The renamer should use the `T8743.hs`’s definition of `ToRow`, even if a (less useful) definition is already known from a boot file. Edward, does this explanation help you hunt down the problem? I know little about the plumbing of the various environments and such. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: | https://phabricator.haskell.org/D860 -------------------------------------+------------------------------------- Comment (by nomeata): Looks like SPJ fixed this as I was talking: changeset:9b9fc4c732baab126b057b4031bebcbd67d6e348 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: | https://phabricator.haskell.org/D860 -------------------------------------+------------------------------------- Comment (by simonpj): Current status is confusing: * This ticket is about self-SOURCE import, and will be fixed by Phab:D860. * When Phab:D860 is applied, it reveals yet another bug: symptoms in comment:9. Simon fixed this new bug comment:10. * Independently, the test for #8473 was marked as failing because of the Lint arity error, even with `--make`, but Simon's fix fixed that. Conclusion: just commit Phab:D862 (remove self-SOURCE imports from test suite) and Phab:D860 (fix this ticket) and everything will be fine. Edward will do this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10182: lookupIfaceGlobal crash with SOURCE import
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: ezyang
Type: bug | Status: patch
Priority: normal | Milestone: 7.12.1
Component: Compiler | Version: 7.8.4
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
| https://phabricator.haskell.org/D860
-------------------------------------+-------------------------------------
Comment (by Edward Z. Yang

#10182: lookupIfaceGlobal crash with SOURCE import
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: ezyang
Type: bug | Status: patch
Priority: normal | Milestone: 7.12.1
Component: Compiler | Version: 7.8.4
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
| https://phabricator.haskell.org/D860
-------------------------------------+-------------------------------------
Comment (by Edward Z. Yang

#10182: lookupIfaceGlobal crash with SOURCE import -------------------------------------+------------------------------------- Reporter: simonpj | Owner: ezyang Type: bug | Status: closed Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: | https://phabricator.haskell.org/D860 -------------------------------------+------------------------------------- Changes (by ezyang): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10182#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC