[GHC] #12776: Panic Simplifier ticks exhausted since ghc 8

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I'm getting a panic! in GHC 8.0.1 and in 8.1.20161028 {{{ sjoosten:ghcCompileBug sjc$ ghc-8.1.20161028 --make Main.hs -O2 [1 of 2] Compiling Factorize ( Factorize.hs, Factorize.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.1.20161028 for x86_64-apple-darwin): Simplifier ticks exhausted When trying UnfoldingDone $slast_s_s1IU To increase the limit, use -fsimpl-tick-factor=N (default 100) If you need to do this, let GHC HQ know, and what factor you needed To see detailed counts use -ddump-simpl-stats Total ticks: 18241 Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1076:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1080:37 in ghc:Outputable pprPanic, called at compiler/simplCore/SimplMonad.hs:199:31 in ghc:SimplMonad Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Attached is some code which I tried to make as small as possible (it therefore does not make sense, but it reproduces the panic). The panic! only occurs with -O2 (I need the -O2 switch to optimise the automatically generated Haskell code). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sjcjoosten): * Attachment "Factorize.hs" added. PanicForO2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 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 sjcjoosten): * priority: normal => high * failure: None/Unknown => Compile-time crash or panic @@ -5,1 +5,1 @@ - sjoosten:ghcCompileBug sjc$ ghc-8.1.20161028 --make Main.hs -O2 + sjoosten:ghcCompileBug sjc$ ghc-8.1.20161028 --make Factorize.hs -O2 New description: I'm getting a panic! in GHC 8.0.1 and in 8.1.20161028 {{{ sjoosten:ghcCompileBug sjc$ ghc-8.1.20161028 --make Factorize.hs -O2 [1 of 2] Compiling Factorize ( Factorize.hs, Factorize.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.1.20161028 for x86_64-apple-darwin): Simplifier ticks exhausted When trying UnfoldingDone $slast_s_s1IU To increase the limit, use -fsimpl-tick-factor=N (default 100) If you need to do this, let GHC HQ know, and what factor you needed To see detailed counts use -ddump-simpl-stats Total ticks: 18241 Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1076:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1080:37 in ghc:Outputable pprPanic, called at compiler/simplCore/SimplMonad.hs:199:31 in ghc:SimplMonad Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Attached is some code which I tried to make as small as possible (it therefore does not make sense, but it reproduces the panic). The panic! only occurs with -O2 (I need the -O2 switch to optimise the automatically generated Haskell code). -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.0.1 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 sjcjoosten): * priority: high => highest -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8
-------------------------------------+-------------------------------------
Reporter: sjcjoosten | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 8.0.1
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: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Thank you for the small test case. I can see what is happening here.
After `SpecConstr`, and occurrence analysis we get
{{{
Rec {
$slast_s_s1J5
:: forall a_a1BZ. a_a1BZ -> Slist a_a1BZ -> Eq a_a1BZ => a_a1BZ
$slast_s_s1J5 =
\ (@ a_a1BZ)
(sc_s1J0 :: a_a1BZ)
(sc_s1J1 :: Slist a_a1BZ)
(sc_s1IZ :: Eq a_a1BZ) ->
case sc_s1J1 of wild_Xp [Dmd=] ->
case xs_a1kC of {
Nil_s -> x_a1kB;
Cons_s a1_a1zd [Occ=Once] a2_a1ze [Occ=Once] ->
$slast_s_s1J5 @ a_a1BC a1_a1zd a2_a1ze $dEq_a1BE
}
}
end Rec }
}}}
Then in `last_s`:
* `$s_last_s_s1J5` is inlined
* The RULE fires, yielding a new cal to `$s_last_s_s1J5`
* `$s_last_s_s1J5` is inlined again
* and so on.
The problem is that `$s_last_s_s1J5` should be a loop breaker. See the
extensive notes under `Note [Choosing loop breakers]`.
But alas in `occAnalRec` we see this
{{{
pairs :: [(Id,CoreExpr)]
pairs | isEmptyVarSet weak_fvs = reOrderNodes 0 bndr_set weak_fvs
tagged_nodes []
| otherwise = loopBreakNodes 0 bndr_set weak_fvs
loop_breaker_edges []
}}}
We want to go via the `loopBreakNodes` call, but actually `weak_fvs` is
empty so we go via the former call.
I'm not yet sure exactly why... just recording breadcrumbs for now.
How urgent is this for you, Stef?
--
Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:3
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.0.1 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: | -------------------------------------+------------------------------------- Comment (by sjcjoosten): We have several work-arounds for now: using an old GHC version, turning off optimisations, and using other code without this behavior, so I'm fine right now. From your analysis, I should be able to come up with a no- inline pragma too. I only raised the priority to increase the visibility: didn't want this to go unnoticed before the next release, so thank you for taking a look at it! Regards, Sebastiaan (PS: Stef is my dad) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8
-------------------------------------+-------------------------------------
Reporter: sjcjoosten | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 8.0.1
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: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: #12843 #12675 | Differential Rev(s): #12789 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by MikolajKonarski): * related: => #12843 #12675 #12789 Comment: FYI: #12843 shows an example (a huge one, unfortunately), which crashes similarly with any optimization level and with older GHCs as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8
-------------------------------------+-------------------------------------
Reporter: sjcjoosten | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: #12843 #12675 | Differential Rev(s):
#12789 |
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#12776: Panic Simplifier ticks exhausted since ghc 8
-------------------------------------+-------------------------------------
Reporter: sjcjoosten | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: #12843 #12675 | Differential Rev(s):
#12789 |
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: merge Priority: highest | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash or panic | simplCore/should_compile/T12776 Blocked By: | Blocking: Related Tickets: #12843 #12675 | Differential Rev(s): #12789 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => simplCore/should_compile/T12776 * status: new => merge Comment: Big thank you to sjcjoosten for making such a tractable test case. THANKS! It's great to have this one nailed. Worth merging this (or the key part anyway) to 8.0.3 Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: Type: bug | Status: merge Priority: highest | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash or panic | simplCore/should_compile/T12776 Blocked By: | Blocking: Related Tickets: #12843 #12675 | Differential Rev(s): #12789 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: => 8.0.3 Comment: Punting to 8.0.3 in the interest of getting 8.0.2 out. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12776: Panic Simplifier ticks exhausted since ghc 8 -------------------------------------+------------------------------------- Reporter: sjcjoosten | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash or panic | simplCore/should_compile/T12776 Blocked By: | Blocking: Related Tickets: #12843 #12675 | Differential Rev(s): #12789 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12776#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC