[GHC] #10946: Typed hole inside typed Template Haskell bracket causes panic

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template | Version: 7.10.1 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | -------------------------------------+------------------------------------- When I say: {{{#!hs m :: a -> a m x = $$([||_||]) }}} I get: {{{ T10946.hs:47:13:ghc: panic! (the 'impossible' happened) (GHC version 7.10.1 for x86_64-unknown-linux): No skolem info: a_apJ[sk] }}} This happens both with GHC 7.10.1 and latest HEAD (e2b579e8d77357e8b36f57d15daead101586ac8e). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Comment (by jstolarek): This error is raised in `TcErrors.getSkolemInfo` called from `TcErrors.mkHoleError`. Quick look at the code tells me that "implication constraints" are expected to be non-empty but they are. Are implication constraints things that come in the contexts, ie. everything before a `=>`? Why are they expected to be non-empty? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: high | Milestone: 8.0.1
Component: Template Haskell | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Jan Stolarek

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Changes (by jstolarek): * testcase: => th/T10946 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: high | Milestone: 8.0.1
Component: Template Haskell | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case: th/T10946
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Jan Stolarek

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.1 => 8.2.1 Comment: This still fails and won't be fixed for 8.0.1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: high | Milestone: 8.2.1
Component: Template Haskell | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case: th/T10946
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.4.1 Comment: It looks like this won't happen for 8.2 either. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by elliottt): The problem seems to be that the quoted expression {{{[|| _x ||]}}} will introduce a hole constraint of the form {{{ _x :: a }}} when spliced, but that the error will be reported outside of the implication introduced by the signature. When checking the following program: {{{ m :: a m = _x }}} {{{simplifyTop}}} will report that it's found an unsolved wanted constraint of the form {{{ forall (a :: *). () => _x :: a }}}. However, when checking the original program, {{{simplifyTop}}} is called from a different path ({{{tcTopSpliceExpr}}}), and reports the wanted constraint as being of the form {{{ _x :: a }}}. As it lacks the context of the binding for {{{a}}}, it falls through to the base case of {{{getSkolemInfo}}}, which causes the panic. At this point, I'm not sure what the right path forward is. Should {{{tcTopSpliceExpr}}} be using {{{simplifyTop}}}, or is there just some additional context needed to be setup before that call? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): So in f64f7c36ef9395da1cc7b686aaf1b019204cd0fc, we added a test case for this that was marked as `expect_broken`. However, that program now loops infinitely on GHC HEAD! {{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 8.5.20180305: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> :set -XTemplateHaskell λ> m :: a -> a; m x = $$([||_||]) -- Loops infinitely ^CInterrupted. }}} Should we disable the test case entirely in the meantime? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): A correction to comment:9—it doesn't loop infinitely, but it does take a full five minutes to complete that test case on my machine. Still, that's quite severe—we should find out what caused this to regress. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: Tritlo (added) Comment: It looks like much of the slowdown was introduced in commit cbdea95938bf09e8e3e7be31918549224d171873 (`Sort valid substitutions for typed holes by "relevance"`). Tritlo, do you have any idea what might be happening here? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Tritlo): RyanGlScott: It seems like what's happening is that since the variable has no constraints on it at all, then it's matching everything in scope (including everything in scope in TemplateHaskell), and then doing the subsumption graph sorting on that, which takes a very long time. I'll give it some thought, but it seems like the right way to go would be to not try to find valid substitutions for this too general case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Or just to limit the maximum number of substitutions to ten, or something arbitrary like that. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Tritlo): On the other hand, this is the right behavior, since a type variable with no constraints on it could be substituted with any identifier of any type. So the time it is taking is really due to the bug giving the hole a too general type. simonpj: Yes, that's a good point. When we don't try to sort the substitution, that is indeed what happens. We should set some limit for how many substitutions we attempt to sort by the subsumption graph method, and default to some other method otherwise (like e.g. sorting by module). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: #14969 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #14969 Comment: #14969 is the new home for the performance issue brought up in comment:9. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner: (none)
Type: bug | Status: new
Priority: high | Milestone: 8.4.1
Component: Template Haskell | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case: th/T10946
Blocked By: | Blocking:
Related Tickets: #14969 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.6.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: #14969 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.4.1 => 8.6.1 Comment: Tritlo, is this now fixed? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.6.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: #14969 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Tritlo): No, the initial error still occurs, but the hang introduced by the valid hole fits should no longer be a problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10946: Typed hole inside typed Template Haskell bracket causes panic -------------------------------------+------------------------------------- Reporter: jstolarek | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.10.1 Component: Template Haskell | Version: 7.10.1 Resolution: | Keywords: | TypedTemplateHaskell Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: th/T10946 Blocked By: | Blocking: Related Tickets: #14969 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: => TypedTemplateHaskell -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10946#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC