Ticket #7110 (closed bug: duplicate)

Opened 10 months ago

Last modified 9 months ago

Stack overflow when compiling with optimizations

Reported by: EyalLotem Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime crash Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

This program:

import Control.Exception (evaluate)

main :: IO ()
main = do
  let smap = concat . replicate 300 $ concat [" ", replicate 2027 '#', " \n"]
  evaluate $ fst (stringReader 1 smap)

stringReader :: Int -> String -> ((), String)
stringReader 1 ('\r':'\n':_) = ((), "")
stringReader _ ('\n':cs) = stringReader 1 cs -- unix
stringReader x (_:cs) = stringReader x cs
stringReader _ _ = ((), "")

Causes a stack overflow when compiled with -O2, and no problem when compiled without optimizations.

Change History

Changed 10 months ago by EyalLotem

Note that "smap" is not the culprit (it has the same result when reading smap from a file via readFile).

stringReader is the culprit.

If the argument order to stringReader is flipped, the stack overflow goes away.

Changed 9 months ago by simonpj

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to duplicate

Happily this is already fixed; it's a dup of #5920 and #5997.

Simon

Note: See TracTickets for help on using tickets.