[GHC] #12212: GHC 8.0.1 crash

#12212: GHC 8.0.1 crash
-------------------------------------+-------------------------------------
Reporter: dibblego | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Keywords: | Operating System: Linux
Architecture: | Type of failure: Compile-time
Unknown/Multiple | crash
Test Case: | Blocked By:
Blocking: | Related Tickets: 9160, 10602
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Attempting to install the geodetics package results in a GHC 8.0.1 crash.
{{{
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.1
% uname -a
Linux moron 4.6.2-1-ARCH #1 SMP PREEMPT Wed Jun 8 08:40:59 CEST 2016
x86_64 GNU/Linux
% cabal install geodetics-0.0.4
...omitted
[2 of 9] Compiling Geodetics.Ellipsoids ( src/Geodetics/Ellipsoids.hs,
dist/dist-sandbox-49e45c7e/build/Geodetics/Ellipsoids.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.1 for x86_64-unknown-linux):
Template variable unbound in rewrite rule
Variable: cobox_scSX
Rule "SPEC t @ a @ 'DQuantity @ 'DQuantity @ d @ d' @ 'DQuantity @
'DQuantity @ d @ d' @ 'DQuantity @ 'DQuantity @ d @ d'"
Rule bndrs: [cobox_scSX, cobox_scSY, cobox_scSZ, cobox_scT0,
cobox_scT1, $dKnownVariant_scT2, $dKnownVariant_scT3,
$dKnownVariant_scT4, $dKnownVariant_scT5,
$dKnownVariant_scT6,
$dKnownVariant_scT7, $dNum_scT8]
LHS args: [TYPE: a_ac0a, TYPE: 'DQuantity, TYPE: 'DQuantity,
TYPE: d_ac0b, TYPE: d'_ac0c, TYPE: 'DQuantity, TYPE:
'DQuantity,
TYPE: d_ac0b, TYPE: d'_ac0c, TYPE: 'DQuantity, TYPE:
'DQuantity,
TYPE: d_ac0b, TYPE: d'_ac0c, CO:

#12212: GHC 8.0.1 crash -------------------------------------+------------------------------------- Reporter: dibblego | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: 9160, 10602 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dibblego): % cabal --ghc-options="-O0" install geodetics-0.0.4 Installs successfully. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12212#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12212: GHC 8.0.1 crash -------------------------------------+------------------------------------- Reporter: dibblego | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: 9160, 10602 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Interesting. Indeed I can reproduce this with both `-O1` and `-O2`. Thanks for the report! It looks like the two term-level binders Here is a more minimal testcase reproducing the issue with only `dimensional` (install with `cabal install dimensional`), {{{#!hs {-# LANGUAGE TypeOperators, TypeFamilies #-} module Geodetics.Ellipsoids where import Numeric.Units.Dimensional import Numeric.Units.Dimensional.Prelude import Prelude () -- Numeric instances. -- | 3d vector as @(X,Y,Z)@. type Vec3 a = (a,a,a) -- | 3x3 transform matrix for Vec3. type Matrix3 a = Vec3 (Vec3 a) -- | Multiply a matrix by a vector in the Dimensional type system. transform3 :: (Num a) => Matrix3 (Quantity d a) -> Vec3 (Quantity d' a) -> Vec3 (Quantity (d*d') a) transform3 (tx,ty,tz) v = (t tx v, t ty v, t tz v) where t (x1,y1,z1) (x2,y2,z2) = x1*x2 + y1*y2 + z1*z2 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12212#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12212: GHC 8.0.1 crash -------------------------------------+------------------------------------- Reporter: dibblego | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: 9160, 10602 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Indeed something smells a bit fishy here. Looking at rule in question, we see that the coercion variable which is supposed unbound (`cobox_s1TP`) is trivially provided by `Refl`. {{{ [LclId, Arity=10, Str=DmdType, RULES: "SPEC t @ a @ 'DQuantity @ 'DQuantity @ d @ d' @ 'DQuantity @ 'DQuantity @ d @ d'" [ALWAYS] forall (cobox_s1TP :: ((d_a1Fl * d'_a1Fm) :: Dimension) GHC.Prim.~# ((d_a1Fl * d'_a1Fm) :: Dimension)) ... }}} It looks like `specialise/Rules.hs:matchN` has some logic for handling unbound type variables which will fill in with `Any`; however this is a coercion variable, so we instead fail. I wonder if coercion variables also need some special treatment. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12212#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12212: GHC 8.0.1 crash -------------------------------------+------------------------------------- Reporter: dibblego | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: 9160, 10602 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I'll fix this -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12212#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12212: GHC 8.0.1 crash
-------------------------------------+-------------------------------------
Reporter: dibblego | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Linux | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case:
Blocked By: | Blocking:
Related Tickets: 9160, 10602 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#12212: GHC 8.0.1 crash -------------------------------------+------------------------------------- Reporter: dibblego | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | simplCore/should_compile/T12212 Blocked By: | Blocking: Related Tickets: 9160, 10602 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => simplCore/should_compile/T12212 Comment: Good bug thank you! Probably worth merging. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12212#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12212: GHC 8.0.1 crash -------------------------------------+------------------------------------- Reporter: dibblego | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | simplCore/should_compile/T12212 Blocked By: | Blocking: Related Tickets: 9160, 10602 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: => 8.0.2 Comment: Merged to `ghc-8.0` as 3ee5eedf87a13e720b97112517ce250046879eaa. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12212#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC