[GHC] #10031: coerce can cause compiler to loop
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Keywords: | Operating System: Unknown/Multiple Architecture: x86_64 | Type of failure: Compile-time (amd64) | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- This program causes GHC to loop at compile time {{{ {-# LANGUAGE ScopedTypeVariables #-} import Data.Coerce coerce' :: Coercible b a => a -> b coerce' = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b }}} I encountered this trying to use a similar construction in https://github.com/glguy/profunctors/blob/coerce/src/Data/Profunctor/Unsafe.... I'm not absolutely certain about what aspect of this snippet is looping the compiler, but it's pretty small. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by nomeata): * cc: goldfiere (added) Comment: JFTR, this does not loop with 7.8.4, so it is likely related to the Coercible solver rewrite. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonpj): * owner: => goldfire Comment: Richard, might you look at this? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): Confirmed with GHC HEAD. Here is the repeating tail of `-ddump-tc-trace` (not sure if it is useful) {{{ updWorkList WL {Eqs = [G] cobox_am7 :: Coercible b_am6[sk] a_am5[sk] (CTyEqCan)} Start solver pipeline { work item = [G] cobox_am7 :: Coercible b_am6[sk] a_am5[sk] (CTyEqCan) inerts = Equalities: [G] cobox_amr :: Coercible b_amq[sk] a_amp[sk] (CTyEqCan) Type-function equalities: Dictionaries: Irreds: Insolubles = {} Solved dicts runStage canonicalization { workitem = [G] cobox_am7 :: Coercible b_am6[sk] a_am5[sk] (CTyEqCan) canEqTyVar b_am6[sk] a_am5[sk] Not-swapped flattenTyVar1 a_am5[sk] * canEqTyVar flat LHS b_am6[sk] b_am6[sk] a_am5[sk] Not-swapped a_am5[sk] end stage canonicalization } runStage interact with inerts { workitem = [G] cobox_am7 :: Coercible b_am6[sk] a_am5[sk] (CTyEqCan) Can't solve tyvar equality LHS: b_am6[sk] :: * RHS: a_am5[sk] :: * TcLevel = 3 Kick out, tv = b_am6[sk] n-kicked = 1 n-kept fun-eqs = 0 WL {Eqs = [G] cobox_amr :: Coercible b_amq[sk] a_amp[sk] (CTyEqCan)} end stage interact with inerts } 1832[U:3<C:0,F:0>] Kept as inert (1 kicked out): [G] cobox_am7 :: Coercible b_am6[sk] a_am5[sk] End solver pipeline (discharged) } inerts = Equalities: [G] cobox_am7 :: Coercible b_am6[sk] a_am5[sk] (CTyEqCan) Type-function equalities: Dictionaries: Irreds: Insolubles = {} Solved dicts updWorkList WL {Eqs = [G] cobox_amr :: Coercible b_amq[sk] a_amp[sk] (CTyEqCan)} }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): Thanks to glguy for such a nice, tiny test case and to Joachim (nomeata) for the dump. I'm able to solve this without testing! Just add a critical missing `not` in the bowels of `kick_out`. Will validate and push shortly. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D630 -------------------------------------+------------------------------------- Changes (by goldfire): * differential: => Phab:D630 Comment: Just using Phab to validate... I don't think this needs external eyes to review. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D630 -------------------------------------+------------------------------------- Comment (by Richard Eisenberg <eir@…>): In [changeset:"cecf036fa10830a5e9861d1e6a2f8c22059fb4bb/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="cecf036fa10830a5e9861d1e6a2f8c22059fb4bb" Fix #10031 by inverting a critical test in kick_out. Summary: The documentation (Note [The flattening story] in TcFlatten) was correct; it's just the implementation that was not. Test in typecheck/should_compile/T10031 Test Plan: validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D630 GHC Trac Issues: #10031 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: goldfire Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | typecheck/should_compile/T10031 Related Tickets: | Blocking: | Differential Revisions: Phab:D630 -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => merge * testcase: => typecheck/should_compile/T10031 Comment: Please merge for 7.10.1. This is a clear error and should be dead simple to merge. Thanks! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10031: coerce can cause compiler to loop -------------------------------------+------------------------------------- Reporter: glguy | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash | Test Case: Blocked By: | typecheck/should_compile/T10031 Related Tickets: | Blocking: | Differential Revisions: Phab:D630 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed * milestone: => 7.10.1 Comment: Merged to `ghc-7.10` (via 2387369c498f631bd3f4be2d6efe71773353acc5). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10031#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC