Ticket #2327 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

-O flag produces faulty code

Reported by: orenbenkiki Owned by: simonmar
Priority: normal Milestone: 6.10.1
Component: Runtime System Version: 6.9
Keywords: Optimizer -O Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The -O flag generates incorrect code in both 6.8.2 and 6.9.

I tested it myself on 6.8.2 - The -O flag causes the program to enter a 100% CPU endless loop

Heffalump also tested it on 6.9 - The -O flag causes it to segfault

Attached is a tgz file containing the code (and the input).

ghc --make -o obk Main.hs ; obk -> works

ghc --make -o obk -O Main.hs ; obk -> fails

Attachments

Obk.tgz Download (18.5 KB) - added by orenbenkiki 5 years ago.
Program failing to compile with -O

Change History

Changed 5 years ago by orenbenkiki

Program failing to compile with -O

Changed 5 years ago by ganesh

I (Heffalump) only tried with 6.9.20080316, by the way, so it may yet be fixed more recently.

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • component changed from Compiler to Runtime System
  • milestone set to 6.10.1

Copying the mtl and haskell-src code in and I can reproduce this with the HEAD:

$ happy Language/Haskell/Parser.ly
$ ghc  -fforce-recomp -XMultiParamTypeClasses -XFunctionalDependencies -XTypeSynonymInstances -XFlexibleInstances --make -O -o obk Main.hs
$ ./obk
[...]
Keep l_yaml_stream_F_0
obk: internal error: scavenge: unimplemented/strange closure type 28 @ 0x2adffca5c428
    (GHC version 6.9.20080606 for x86_64_unknown_linux)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Changed 5 years ago by simonmar

  • owner set to simonmar

I'm on this one, looks like a problem with the thunk-selector machinery (again; surprise surprise).

Changed 5 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

Fixed:

Tue Jul 29 16:05:18 BST 2008  Simon Marlow <marlowsd@gmail.com>
  * FIX #2327: a fault in the thunk-selector machinery (again)
  This program contains an expression of the form
  
     let x = snd (_, snd (_, snd (_, x)))
  
  (probably not explicitly, but that's what appears in the heap at
  runtime).  Obviously the program should deadlock if it ever enters
  this thing, but apparently the test program in #2327 never does.
  
  The GC tries to evaluate the snd closures, and gets confused due to
  the loop.  In particular the earlier fix for #1038 was to blame.

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.