#3677: Optimizer creates stack overflow on filtered CAF
----------------------------+-----------------------------------------------
Reporter: jpet | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.10.4
Resolution: | Keywords:
Difficulty: | Os: Windows
Testcase: | Architecture: x86
Failure: Runtime crash |
----------------------------+-----------------------------------------------
Changes (by igloo):
* difficulty: =>
Old description:
> The following code creates a stack overflow at -O1 or -O2, when running
> with a moderately small stack (+RTS -K94k):
>
> import Data.Bits
> hmm :: [Integer]
> hmm = filter (\n -> (n .&. (n-1))==0) [1..]
> main = mapM_ print hmm
>
> The lambda just picks out powers of two, so that filter will skip
> increasingly long subsequences. It's the filter causing the overflow.
>
> Changing hmm to [Int], or to be let-bound, or compiling with -O0 makes
> the overflow go away. Using a 95k stack also makes the overflow go away.
> (Below 95k, stack usage is linear with the length of the filtered-out
> subsequence; then it seems to cap out.)
New description:
The following code creates a stack overflow at -O1 or -O2, when running
with a moderately small stack (+RTS -K94k):
{{{
import Data.Bits
hmm :: [Integer]
hmm = filter (\n -> (n .&. (n-1))==0) [1..]
main = mapM_ print hmm
}}}
The lambda just picks out powers of two, so that filter will skip
increasingly long subsequences. It's the filter causing the overflow.
Changing hmm to [Int], or to be let-bound, or compiling with -O0 makes the
overflow go away. Using a 95k stack also makes the overflow go away.
(Below 95k, stack usage is linear with the length of the filtered-out
subsequence; then it seems to cap out.)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3677#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs