[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=<L,A>] { Nil_s -> sc_s1J0; Cons_s _ [Occ=Dead] _ [Occ=Dead] -> let { sc_s1J1 [Occ=Once] :: Slist a_a1BZ [LclId] sc_s1J1 = wild_Xp } in last_s @ a_a1BZ sc_s1IZ sc_s1J1 } last_s [Occ=LoopBreaker] :: forall a_a1kp. Eq a_a1kp => Slist a_a1kp -> a_a1kp [RULES: "SC:last_s0" [ALWAYS] forall (@ a_a1BZ) (sc_s1J0 :: a_a1BZ) (sc_s1J1 :: Slist a_a1BZ) (sc_s1IZ :: Eq a_a1BZ). last_s @ a_a1BZ sc_s1IZ (Cons_s @ a_a1BZ sc_s1J0 sc_s1J1) = $slast_s_s1J5 @ a_a1BZ sc_s1J0 sc_s1J1 sc_s1IZ] last_s = \ (@ a_a1BC) ($dEq_a1BE :: Eq a_a1BC) (ds_d1Do [Occ=Once!] :: Slist a_a1BC) -> case ds_d1Do of { Nil_s -> lvl_s1Fa @ a_a1BC; Cons_s x_a1kB [Occ=Once] xs_a1kC [Occ=Once!, Dmd=<S,U>] -> 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 <simonpj@…>): In [changeset:"7fe71636dc14a219c26def5cac2da9fa20689540/ghc" 7fe7163/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="7fe71636dc14a219c26def5cac2da9fa20689540" Adapt the (commented out) pprTrace in OccurAnal I did this while investigating Trac #12776 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12776#comment:5> 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: | -------------------------------------+------------------------------------- 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 <simonpj@…>): In [changeset:"6ec2304f46c9a5423943c5bf29bd8a8c062b6560/ghc" 6ec2304f/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="6ec2304f46c9a5423943c5bf29bd8a8c062b6560" Fix an long-standing bug in OccurAnal This bug was beautifully characterised in Trac #12776, which showed a small program for which the inliner went into an infinite loop. Eeek. It turned out to be a genuine and long-standing bug in the occurrence analyer, specifically in the bit that identifies loop breakers. In this line pairs | isEmptyVarSet weak_fvs = reOrderNodes 0 bndr_set weak_fvs tagged_nodes [] | otherwise = loopBreakNodes 0 bndr_set weak_fvs loop_breaker_edges [] the 'tagged_nodes' should be 'loop_breaker_edges'. That's it! The diff looks a lot bigger because I did some work on comments and variable naming, but that's all it is. We were using the wrong set of dependencies! I'm astonished that this bug has not caused more trouble. It dates back to at least 2011 and maybe further. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12776#comment:7> 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 <simonpj@…>): In [changeset:"605af54aee76cd3d02afb60ff0b0dde052645fe7/ghc" 605af54a/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="605af54aee76cd3d02afb60ff0b0dde052645fe7" Test Trac #12776 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12776#comment:8> 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: 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