[GHC] #7898: Compiler diverges when compiling module BSP of frag-1.1.2

#7898: Compiler diverges when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- GHC will get stuck when trying to compile [http://www.haskell.org/haskellwiki/Frag Frag]. Steps to reproduce: 1. Get Frag 1.1.2 from the Darcs repository (`darcs get http://code.haskell.org/frag`), or from snowmantw's !GitHub fork (`git clone https://github.com/snowmantw/Frag.git`). 1. Fix the code so it'll actually compile: {{{ diff --git a/src/Textures.hs b/src/Textures.hs index 7383fd8..b5516a5 100644 --- a/src/Textures.hs +++ b/src/Textures.hs @@ -10,6 +10,7 @@ import Graphics.UI.GLUT import TGA (readTga) import Data.Word (Word8) import Foreign.Marshal.Alloc (free) +import Control.Exception (catch, SomeException) -- read a list of images and returns a list of textures @@ -32,7 +33,8 @@ getAndCreateTexture fileName = do -- read the image data readImageC :: String -> IO (Maybe (Size, PixelData Word8)) -readImageC path = catch (readTga path) (\_ -> do print ("missing texture: "++path) +readImageC path = catch (readTga path) (\e -> do print (e :: SomeException) + print ("missing texture: "++path) return Nothing) }}} 1. `cabal configure` 1. `cabal build` GHC will get stuck on the module `BSP` and consume memory until it crashes. According to [https://github.com/snowmantw/Frag/issues/1 this ticket on the GitHub fork mentioned earlier], this problem only occurs with `-O2`. When I split the reading part of the module (`readBSP` and all functions it depends on), it crashed on that part. Will investigate further. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: Compiler diverges when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by tinctorius): `-O2` seems to be the culprit. When removing the flag from the Cabal file, it'll compile. Eventually. {{{ diff --git a/frag.cabal b/frag.cabal index 8893fb0..3c32cdf 100644 --- a/frag.cabal +++ b/frag.cabal @@ -85,7 +85,6 @@ Executable frag Main-is: Main.hs Build-Depends: base==4.*, GLUT, OpenGL>=2.0, array, random Hs-source-dirs: src - Ghc-options: -O2 -funbox-strict-fields -fvia-C -optc-O2 Extensions: BangPatterns, FunctionalDependencies, FlexibleInstances, }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: Compiler diverges when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by exbb2): I remember that this bug has been already in ghc-7.2.1 or in ghc-7.0.1 — i tried to compile frag about a year ago; didn't knew that darcs repo contains version that builds for newer ghc, had to patch it until i got to BSP. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: Compiler diverges when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by amosrobinson): This looks somewhat similar to #5550, but is not the same. SpecConstr is indeed blowing up massively: {{{ Result size of Simplifier = 291502 *** SpecConstr: Result size of SpecConstr = 3164185 }}} but it does terminate eventually (for me on 7.4.2, at least). I have a tentative patch to try removing some SpecConstr blowups (by seeding specialisation for top-level bindings similar to what is already done for letrecs) but I won't get a chance to try that on this example until Monday. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: Compiler diverges when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by amosrobinson): For now, though, you could try compiling with {{{-O2 -fno-spec-constr}}}. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: SpecConstr explodes when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by tinctorius): Splitting off `cIntSize`, `getLumpData`, `kIndices`, `readHeader`, `readIndices`, and `readLump` into a separate module greatly reduces the problem. It still takes unreasonably long to compile, though. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: SpecConstr explodes when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by amosrobinson): Annoyingly, GLUT won't install on ghc-head at the moment, and the BSP module seems to actually rely on GLUT for something. I'll see if I can split out the reading part without GLUT -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: SpecConstr explodes when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by amosrobinson): This is strange. I managed to get OpenGL to install on head (had to comment out the Typeable instances). Head still has the same blowup problem. Then I split BSP into two modules: reading and rendering. Then, bizarrely, neither of those modules blew up. I don't understand how splitting it into two modules could stop specialisation from happening, but it seems to. Same behaviour on head & 7.4.2. I'm going to try selectively removing/undefining parts of the original BSP until I get something small enough that still blows up but the core is readable. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: SpecConstr explodes when compiling module BSP of frag-1.1.2 -------------------------------+-------------------------------------------- Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Compile-time crash | Blockedby: Blocking: | Related: -------------------------------+-------------------------------------------- Comment(by amosrobinson): Haha! if you remove the export list is compiles immediately! -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: SpecConstr explodes when compiling module BSP of frag-1.1.2 ---------------------------------+------------------------------------------ Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonpj): * difficulty: => Unknown Comment: Amos, it sounds as if you are onto something! Great. If you can boil it down to something I can reproduce without massive heroics, and if you are stuck, I'll willingly take a look. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: SpecConstr explodes when compiling module BSP of frag-1.1.2 ---------------------------------+------------------------------------------ Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by amosrobinson): I'm sorry, I've kind of dropped the ball on this. So, SpecConstr is definitely blowing up (235,000 to 3,000,000 or something). But! Before that, the simplifier is blowing up from 5,000 to 235,000. I know a certain amount of increase is expected from inlining in the simplifier, but this seems excessive. So I suspect it's actually inlining too much? I don't have a good example, but #7928 looks like it might be easier to get into a standalone test case. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7898: SpecConstr explodes when compiling module BSP of frag-1.1.2 ---------------------------------+------------------------------------------ Reporter: tinctorius | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: Compile-time crash Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by simonpj): OK, thanks Amos. I'm utterly snowed under, so you are holding the token on this `SpecConstr` blowup (thank you). Everyone else: yell if this is mission-critical. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7898#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (2)
-
GHC
-
GHC