[GHC] #11106: Optimizer changes behavior in 7.10.3

#11106: Optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: -------------------------------------+------------------------------------- The repository at https://github.com/ddssff/ghcbug contains a four module package that works when compiled with -O2, but fails when compiled with -O2. The cabal file builds working and failing executable. One of the modules has OPTIONS_GHC -O0 in the header, so the bug is related to mixing modules with different optimization levels. Other than that, I have little idea what is going on. The bug was present in 7.10,2, and is definitely still present in 7.10.3-rc1. I doubt it has been fixed since then. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by simonpj): I guess you "works with -O0"? What does "fails when compiled with -O2" mean? Fails in what way? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by dsf): Without the optimizer it outputs a haskell expression generated by Show. With, it says "bug: <<loop>>" and exits with a failure code. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Description changed by dsf: Old description:
The repository at https://github.com/ddssff/ghcbug contains a four module package that works when compiled with -O2, but fails when compiled with -O2. The cabal file builds working and failing executable.
One of the modules has OPTIONS_GHC -O0 in the header, so the bug is related to mixing modules with different optimization levels. Other than that, I have little idea what is going on.
The bug was present in 7.10,2, and is definitely still present in 7.10.3-rc1. I doubt it has been fixed since then.
New description: The repository at https://github.com/ddssff/ghcbug contains a four module package that works when compiled with -O0, but fails when compiled with -O2. The cabal file builds working and failing executable. One of the modules has OPTIONS_GHC -O0 in the header, so the bug is related to mixing modules with different optimization levels. Other than that, I have little idea what is going on. The bug was present in 7.10,2, and is definitely still present in 7.10.3-rc1. I doubt it has been fixed since then. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by rwbarton): This project's dependencies took 45 minutes to build. Can you provide a stripped-down reproducer? It helps greatly when testing with different versions of GHC. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by dsf): I just pushed a patch that eliminates the safecopy and uuid dependencies. I'm afraid the main culprit is probably lens, which will be a little harder to remove. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by rwbarton): How about haskell-src-exts, pandoc, etc.? It looks like you import virtually none of these. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by dsf): I those are definitely gone - do you have the latest commits? Its just base, lens, syb, text, ListLike, containers -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by dsf): Dependency list is now just base, microlens, containers. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata): You can simply copy the microlens files into `src/`, and it becomes reproducible with GHC HEAD without any further packages or downloads (containers comes with GHC). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata):
Without the optimizer it outputs a haskell expression generated by Show. With, it says "bug: <<loop>>" and exits with a failure code.
It is not related to `Show`; simply `seq`’ing the first `ReportMap` sufficies. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata): Further simplification, removal of derived instances and spreading things out over multiple modules shows that `-O0` has to apply to these four lines only for the bug to occur: {{{ instance Eq ReportElemID where (==) a b = (==) (unReportElemID a) (unReportElemID b) instance Ord ReportElemID where compare a b = compare (unReportElemID a) (unReportElemID b) instance Enum ReportElemID where toEnum = (ReportElemID . toEnum) fromEnum = (fromEnum . unReportElemID) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata): Changing {{{ -class Ord k => OrderKey k where +class OrderKey k where }}} in `Order.hs` and adding `Ord k` instances to methods and functions as required also makes the problem go away. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata): I’m doing further simplification in my fork at https://github.com/nomeata /ghc-bug-11106. No microlens needed any more. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata): The test case is now narrowed down a lot, 60 lines in total. The problem seems to be related to polymorphic, exported definitions: If I start to remove type signatures or to merge some of the module, it disappears. This needs looking into by someone with knowledge about the constraint solver. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata): It should be noted that the program runs fine if all modules are built with `-O0`, as well as when all modules are built with `-O`. Just the combination of `-O` passed to ghc, but `-O0` passed to that one module breaks. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by nomeata): JFTR, the bug is also in HEAD, but not in 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Comment (by dsf): This could use a milestone. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11106: Turning on optimizer changes behavior in 7.10.3 -------------------------------------+------------------------------------- Reporter: dsf | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.10.2 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 thomie): * priority: normal => high -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11106#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC