[GHC] #15499: Panic in occurence analysis phase (?), getRuntimeRep
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Keywords: | Operating System: Linux Architecture: | Type of failure: Compile-time Unknown/Multiple | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Compiling this: {{{#!hs {-# LANGUAGE DataKinds, GADTs, KindSignatures #-} module Holo () where data ADT (p :: Integer) where ADT :: { a :: a , b :: Integer } -> ADT p foo = undefined {b=undefined} }}} ..yields: {{{ ghc: panic! (the 'impossible' happened) (GHC version 8.4.3 for x86_64-unknown-linux): getRuntimeRep p_a29z :: Integer Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:1967:18 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -v4 suggests this happend during the occurence analysis phase (log attached). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by _deepfire): * Attachment "ghc-843-panic.log" added. ghc -c Holo.hs -v4 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by _deepfire): Potentially related are #14786 and #14175, due to also being `getRuntimeRep` panics (#14175 only had it for 8.3HEAD). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: new Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * owner: (none) => RyanGlScott * os: Linux => Unknown/Multiple Comment: Ugh, this is my fault. I introduced this regression in ef26182e2014b0a2a029ae466a4b121bf235e4e4 (`Track the order of user-written tyvars in DataCon`). The `-v4` logs are a bit misleading, as the real problem lies in desugaring, not occurrence analysis. Essentially, GHC tries to desugar this: {{{#!hs foo :: forall p. ADT p foo = undefined {b=undefined} }}} Into this: {{{#!hs foo :: forall p. ADT p foo @p = case undefined of ADT @a x y -> ADT @p @a x undefined }}} If the fact that I wrote `ADT @p @a` looks strange to you, that's because it is! The //real// type of the `ADT` constructor is: {{{#!hs ADT :: forall a p. a -> Integer -> ADT p }}} Due to the fact that type variables in GADT type signatures are now quantified in toposorted order after the aforementioned commit. This means that the correct order of arguments //should// be `ADT @a @p`. However, the code in `dsExpr` assumes that the universally quantified type variables always come before the existentially quantified type variables, so `@p` ends up being applied before `@a`, leading to utter disaster and chaos down the line. Thankfully, this isn't too difficult to fix. Patch incoming. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: patch Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D5060 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: patch Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Comment (by _deepfire): RyanGlScott, bgamari, do you think we can get this into 8.4.4? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: patch Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Changes (by _deepfire): * cc: bgamari (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: patch Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): By the way, it's worth noting that working around this issue is very simple: just quantify the type variables in universals-then-existentials order. That is, do this: {{{#!hs data ADT (p :: Integer) where ADT :: forall p a. { a :: a , b :: Integer } -> ADT p }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: patch Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Comment (by _deepfire): RyanGlScott, thank you for the workaround! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: patch Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Krzysztof Gogolewski <krz.gogolewski@…>): In [changeset:"63b6a1d44849c479d2a7cb59211f5c64d133bc62/ghc" 63b6a1d4/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="63b6a1d44849c479d2a7cb59211f5c64d133bc62" Be mindful of GADT tyvar order when desugaring record updates Summary: After commit ef26182e2014b0a2a029ae466a4b121bf235e4e4, the type variable binders in GADT constructor type signatures are now quantified in toposorted order, instead of always having all the universals before all the existentials. Unfortunately, that commit forgot to update some code (which was assuming the latter scenario) in `DsExpr` which desugars record updates. This wound up being the cause of #15499. This patch makes up for lost time by desugaring record updates in a way such that the desugared expression applies type arguments to the right-hand side constructor in the correct order—that is, the order in which they were quantified by the user. Test Plan: make test TEST=T15499 Reviewers: simonpj, bgamari Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15499 Differential Revision: https://phabricator.haskell.org/D5060 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: merge Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: closed Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: deepfire, it's rather unlikely that there will be a 8.4.4. However, I've merged the fix to 8.6.1 and the `ghc-8.4` branch just in case. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: merge Priority: high | Milestone: 8.4.4 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: closed => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15499: Panic in occurence analysis phase (?), getRuntimeRep -------------------------------------+------------------------------------- Reporter: _deepfire | Owner: RyanGlScott Type: bug | Status: closed Priority: high | Milestone: 8.6.2 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5060 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed Comment: Merged to `ghc-8.6` with 0af55c128d06e8c23a6fd68bafe47a5315bea812. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15499#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC