Ticket #2327 (closed bug: fixed)

Opened 6 months ago

Last modified 2 months ago

-O flag produces faulty code

Reported by: orenbenkiki Assigned to: simonmar
Priority: normal Milestone: 6.10.1
Component: Runtime System Version: 6.9
Severity: normal Keywords: Optimizer -O
Cc: Difficulty: Unknown
Test Case: Architecture: Unknown/Multiple
Operating System: Unknown/Multiple

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 (18.5 kB) - added by orenbenkiki on 06/01/08 11:07:50.
Program failing to compile with -O

Change History

06/01/08 11:07:50 changed by orenbenkiki

  • attachment Obk.tgz added.

Program failing to compile with -O

06/01/08 11:13:39 changed by ganesh

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

06/08/08 14:24:28 changed by igloo

  • owner changed.
  • 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

07/29/08 06:45:51 changed by simonmar

  • owner set to simonmar.

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

07/29/08 08:37:48 changed 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.

09/30/08 08:40:37 changed by simonmar

  • architecture changed from Unknown to Unknown/Multiple.

09/30/08 08:51:50 changed by simonmar

  • os changed from Unknown to Unknown/Multiple.