[GHC] #16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction)

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Linux Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The attached program fails to compile with the following error: {{{ ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-unknown-linux): mkNewTyConRhs MV_V [Int#, MVector s_a7WC[sk:1] a_a7WA[sk:1], MVector s_a7WC[sk:1] a_a7WA[sk:1]] Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable pprPanic, called at compiler/iface/BuildTyCl.hs:65:27 in ghc:BuildTyCl }}} Removing either of the -funbox-strict-fields or StrictData pragma allow the code to compile correctly, but you do need to compile with -O to get the incorrect behaviour -ghci is fine loading the module. Although I wouldn't expect them to interact here as I don't get the same behaviour if I explicitly write out what would be implied by the flag and pragma: {{{ data V a = V {-# UNPACK #-} !a {-# UNPACK #-} !a deriving (Show) }}} just warnings about the unused UNPACKs. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dbeacham): * Attachment "Lib.hs" added. Example program -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dbeacham): * Attachment "ghc-panic-deriving-unbox.cabal" added. cabal file -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dbeacham): * Attachment "splice" added. Output from -ddump-splices -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by dbeacham: Old description:
The attached program fails to compile with the following error:
{{{ ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-unknown-linux): mkNewTyConRhs MV_V [Int#, MVector s_a7WC[sk:1] a_a7WA[sk:1], MVector s_a7WC[sk:1] a_a7WA[sk:1]] Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable pprPanic, called at compiler/iface/BuildTyCl.hs:65:27 in ghc:BuildTyCl }}}
Removing either of the -funbox-strict-fields or StrictData pragma allow the code to compile correctly, but you do need to compile with -O to get the incorrect behaviour -ghci is fine loading the module.
Although I wouldn't expect them to interact here as I don't get the same behaviour if I explicitly write out what would be implied by the flag and pragma:
{{{ data V a = V {-# UNPACK #-} !a {-# UNPACK #-} !a deriving (Show) }}}
just warnings about the unused UNPACKs.
New description: The attached program {{{ {-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} module Lib where import qualified Data.Vector.Unboxed as V import Data.Vector.Unboxed.Deriving data V a = V {-# UNPACK #-} !a {-# UNPACK #-} !a deriving (Show) derivingUnbox "V" [t| forall a. V.Unbox a => V a -> (a, a) |] [| \(V a b) -> (a, b) |] [| \(a, b) -> V a b |] }}} fails to compile with the following error: {{{ ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-unknown-linux): mkNewTyConRhs MV_V [Int#, MVector s_a7WC[sk:1] a_a7WA[sk:1], MVector s_a7WC[sk:1] a_a7WA[sk:1]] Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable pprPanic, called at compiler/iface/BuildTyCl.hs:65:27 in ghc:BuildTyCl }}} Removing either of the -funbox-strict-fields or StrictData pragma allow the code to compile correctly, but you do need to compile with -O to get the incorrect behaviour -ghci is fine loading the module. Although I wouldn't expect them to interact here as I don't get the same behaviour if I explicitly write out what would be implied by the flag and pragma: {{{ data V a = V {-# UNPACK #-} !a {-# UNPACK #-} !a deriving (Show) }}} just warnings about the unused UNPACKs. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): That looks bad. Is it possible to repro this without relying on vector? And without TH? Perhaps by writing out the code that TH generates? Could it be #15523? Does it happen in HEAD? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dbeacham): Here's a much shorter example without TH or Vector. {{{ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE StrictData #-} {-# OPTIONS_GHC -funbox-strict-fields #-} module Lib where data V a = V a a deriving (Show) data family Test a newtype instance Test (V a) = V_V (a, a) }}} with this error: {{{ ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-unknown-linux): applyTypeToArgs Expression: V_V @ a_a1BO dt_a1R2 dt_a1R3 Type: forall a. (a, a) -> Test (V a) Args: [TYPE: a_a1BO, dt_a1R2, dt_a1R3] Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreUtils.hs:234:14 in ghc:CoreUtils }}} Removing either StrictData or -funbox-strict-fields makes it compile. Maybe of interest that removing StrictData but adding in explicit strictness compiles OK: {{{ {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -funbox-strict-fields #-} module Lib where data V a = V !a !a deriving (Show) data family Test a newtype instance Test (V a) = V_V (a, a) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields interaction) -------------------------------------+------------------------------------- Reporter: dbeacham | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: duplicate | Keywords: Operating System: Linux | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: #16141 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => duplicate * related: => #16141 * milestone: => 8.8.1 Comment: Thanks for the simpler test case. This is a duplicate of #16141, which has been fixed upstream in HEAD. (Perhaps we should merge the fix into the upcoming 8.6.4 release, though, given the volley of tickets about this.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16191#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16191: GHC Panic deriving unbox vector (StrictData/unbox-strict-fields
interaction)
-------------------------------------+-------------------------------------
Reporter: dbeacham | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: Compiler | Version: 8.6.3
Resolution: duplicate | Keywords:
Operating System: Linux | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: #16141 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Marge Bot
participants (1)
-
GHC