[GHC] #12996: Memory leak in recursion when switching from -O1 to -O2

GHC ghc-devs at haskell.org
Sat Dec 17 14:10:07 UTC 2016


#12996: Memory leak in recursion when switching from -O1 to -O2
-------------------------------------+-------------------------------------
           Reporter:  AndreasK       |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:  Memory leak,   |  Operating System:  Unknown/Multiple
  optimization                       |
       Architecture:                 |   Type of failure:  Runtime
  Unknown/Multiple                   |  performance bug
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 For example code see attachment.

 When compiling with -O1 the code behaves as expected with each loop taking
 about the same amount of time.

 At -O2 each iteration takes (nonlinear) more time than the last and leaks
 memory. It gets slow enough that I never bothered to let it run past 40
 iterations since the slowdown seems to be exponential.

 I initially hit the bug in code using a Set instead of list but turns out
 the issue can be reduced to an example with lists.

 Removing either filter, pattern matching or changing the loop fixes the
 issue.

 I tested it under the following conditions:

 * Compiler flags: -fno-full-laziness/No flags
 * Compiler versions: GHC 8.0.1 and 7.10.3e
 * Operating Systems: Windows 10, Linux Mint

 In every case -O1 works as expected with -O2 showing exponential slowdown
 with each iteration.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12996>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list