Ticket #1938 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

Panic when attempting to generate and pretty print Core

Reported by: darinm Owned by: simonmar
Priority: normal Milestone: 6.8.3
Component: Compiler Version: 6.8.1
Keywords: Cc:
Operating System: MacOS X Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

This program is supposed to map a term in a small core like language into GHC core, and then pretty print the result. This code (with appropriate changes) worked with 6.6.1, but panics on 6.8.1. To reproduce the bug, simply evaluate 'test' in the 'Test' module. Here is the output from that process:

ghci -v -dcore-lint -package ghc Test.hs 
GHCi, version 6.8.1: http://www.haskell.org/ghc/  :? for help
Glasgow Haskell Compiler, Version 6.8.1, for Haskell 98, stage 2 booted by GHC version 6.6.1
Using package config file: /Users/dwm/local/ghc-6.8.1/lib/ghc-6.8.1/package.conf
wired-in package base mapped to base-3.0.0.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0.1.0
wired-in package template-haskell mapped to template-haskell-2.2.0.0
wired-in package ndp not found.
Hsc static flags: -static
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
Loading package base ... linking ... done.
Loading package old-locale-1.0.0.0 ... linking ... done.
Loading package old-time-1.0.0.0 ... linking ... done.
Loading package filepath-1.1.0.0 ... linking ... done.
Loading package directory-1.0.0.0 ... linking ... done.
Loading package array-0.1.0.0 ... linking ... done.
Loading package containers-0.1.0.0 ... linking ... done.
Loading package hpc-0.5.0.0 ... linking ... done.
Loading package bytestring-0.9.0.1 ... linking ... done.
Loading package pretty-1.0.0.0 ... linking ... done.
Loading package packedstring-0.1.0.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package unix-2.2.0.0 ... linking ... done.
Loading package process-1.0.0.0 ... linking ... done.
Loading package readline-1.0.1.0 ... linking ... done.
Loading package Cabal-1.2.2.0 ... linking ... done.
Loading package random-1.0.0.0 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package ghc-6.8.1 ... linking ... done.
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
*** Chasing dependencies:
Chasing modules from: 
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep []
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
*** Chasing dependencies:
Chasing modules from: Test.hs
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep
  [NONREC
      ModSummary {
	 ms_hs_date = Mon Nov 26 23:34:34 PST 2007
	 ms_mod = main:Lib.Syntax.LightWeight.Common,
	 ms_imps = [Data.List]
	 ms_srcimps = []
      },
   NONREC
      ModSummary {
	 ms_hs_date = Mon Nov 26 23:35:23 PST 2007
	 ms_mod = main:Lib.Monad.Reify,
	 ms_imps = [Lib.Syntax.LightWeight.Common, Unique, Type, TyCon, Id,
		    DataCon, Data.Map, Data.IORef, Control.Monad.State,
		    Control.Monad.Reader, Control.Monad.Error, Control.Monad,
		    Control.Applicative, Data.List, Debug.Trace]
	 ms_srcimps = []
      },
   NONREC
      ModSummary {
	 ms_hs_date = Mon Nov 26 23:35:38 PST 2007
	 ms_mod = main:Lib.Syntax.GHC.Common,
	 ms_imps = [Lib.Syntax.LightWeight.Common, Lib.Monad.Reify, TypeRep,
		    Type, TyCon, SrcLoc, OccName, Name, Id, DataCon, CoreSyn,
		    BasicTypes, Data.Maybe, Data.Map, Control.Monad.State,
		    Control.Monad.Reader, Control.Applicative, Debug.Trace]
	 ms_srcimps = []
      },
   NONREC
      ModSummary {
	 ms_hs_date = Mon Nov 26 23:31:51 PST 2007
	 ms_mod = main:Lib.Syntax.LightWeight.Core,
	 ms_imps = [Lib.Syntax.LightWeight.Common]
	 ms_srcimps = []
      },
   NONREC
      ModSummary {
	 ms_hs_date = Mon Nov 26 23:31:49 PST 2007
	 ms_mod = main:Lib.Syntax.GHC.Core,
	 ms_imps = [Lib.Syntax.LightWeight.Core,
		    Lib.Syntax.LightWeight.Common, Lib.Syntax.GHC.Common,
		    Lib.Monad.Reify, Unique, OccName, CoreSyn, Data.Map,
		    Control.Applicative]
	 ms_srcimps = []
      },
   NONREC
      ModSummary {
	 ms_hs_date = Mon Nov 26 23:31:51 PST 2007
	 ms_mod = main:Main,
	 ms_imps = [Lib.Syntax.LightWeight.Core,
		    Lib.Syntax.LightWeight.Common, Lib.Syntax.GHC.Core,
		    Lib.Syntax.GHC.Common, Lib.Monad.Reify, TypeRep, PprCore,
		    Outputable, CoreSyn]
	 ms_srcimps = []
      }]
compile: input file Lib/Syntax/LightWeight/Common.hs
*** Checking old interface for main:Lib.Syntax.LightWeight.Common:
[1 of 6] Compiling Lib.Syntax.LightWeight.Common ( Lib/Syntax/LightWeight/Common.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 2171
*** Core Linted result of Desugar:
*** Simplify:
    Result size = 1896
*** Core Linted result of Simplifier phase 0, iteration 1 out of 4:
    Result size = 1837
*** Core Linted result of Simplifier phase 0, iteration 2 out of 4:
    Result size = 1837
*** Core Linted result of Simplify phase 0 done:
*** Tidy Core:
    Result size = 1908
*** Core Linted result of Tidy Core:
*** CorePrep:
    Result size = 2286
*** Core Linted result of CorePrep:
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
compile: input file Lib/Monad/Reify.hs
*** Checking old interface for main:Lib.Monad.Reify:
[2 of 6] Compiling Lib.Monad.Reify  ( Lib/Monad/Reify.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 1926
*** Core Linted result of Desugar:
*** Simplify:
    Result size = 1743
*** Core Linted result of Simplifier phase 0, iteration 1 out of 4:
    Result size = 1618
*** Core Linted result of Simplifier phase 0, iteration 2 out of 4:
    Result size = 1618
*** Core Linted result of Simplify phase 0 done:
*** Tidy Core:
    Result size = 1697
*** Core Linted result of Tidy Core:
*** CorePrep:
    Result size = 1937
*** Core Linted result of CorePrep:
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
compile: input file Lib/Syntax/GHC/Common.hs
*** Checking old interface for main:Lib.Syntax.GHC.Common:
[3 of 6] Compiling Lib.Syntax.GHC.Common ( Lib/Syntax/GHC/Common.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 950
*** Core Linted result of Desugar:
*** Simplify:
    Result size = 960
*** Core Linted result of Simplifier phase 0, iteration 1 out of 4:
    Result size = 881
*** Core Linted result of Simplifier phase 0, iteration 2 out of 4:
    Result size = 881
*** Core Linted result of Simplify phase 0 done:
*** Tidy Core:
    Result size = 881
*** Core Linted result of Tidy Core:
*** CorePrep:
    Result size = 993
*** Core Linted result of CorePrep:
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
compile: input file Lib/Syntax/LightWeight/Core.hs
*** Checking old interface for main:Lib.Syntax.LightWeight.Core:
[4 of 6] Compiling Lib.Syntax.LightWeight.Core ( Lib/Syntax/LightWeight/Core.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 584
*** Core Linted result of Desugar:
*** Simplify:
    Result size = 446
*** Core Linted result of Simplifier phase 0, iteration 1 out of 4:
    Result size = 454
*** Core Linted result of Simplifier phase 0, iteration 2 out of 4:
    Result size = 454
*** Core Linted result of Simplify phase 0 done:
*** Tidy Core:
    Result size = 454
*** Core Linted result of Tidy Core:
*** CorePrep:
    Result size = 722
*** Core Linted result of CorePrep:
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
compile: input file Lib/Syntax/GHC/Core.hs
*** Checking old interface for main:Lib.Syntax.GHC.Core:
[5 of 6] Compiling Lib.Syntax.GHC.Core ( Lib/Syntax/GHC/Core.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 1083
*** Core Linted result of Desugar:
*** Simplify:
    Result size = 1166
*** Core Linted result of Simplifier phase 0, iteration 1 out of 4:
    Result size = 1100
*** Core Linted result of Simplify phase 0 done:
*** Tidy Core:
    Result size = 1100
*** Core Linted result of Tidy Core:
*** CorePrep:
    Result size = 1261
*** Core Linted result of CorePrep:
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
compile: input file Test.hs
*** Checking old interface for main:Main:
[6 of 6] Compiling Main             ( Test.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 239
*** Core Linted result of Desugar:
*** Simplify:
    Result size = 199
*** Core Linted result of Simplifier phase 0, iteration 1 out of 4:
    Result size = 199
*** Core Linted result of Simplify phase 0 done:
*** Tidy Core:
    Result size = 199
*** Core Linted result of Tidy Core:
*** CorePrep:
    Result size = 223
*** Core Linted result of CorePrep:
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
Ok, modules loaded: Lib.Syntax.LightWeight.Core, Main, Lib.Syntax.LightWeight.Common, Lib.Syntax.GHC.Core, Lib.Syntax.GHC.Common, Lib.Monad.Reify.
*Main> test
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
Loading package mtl-1.1.0.0 ... linking ... done.
let {ghc-6.8.1: panic! (the 'impossible' happened)
  (GHC version 6.8.1 for i386-apple-darwin):
	a static opt was looked at too early!

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Attachments

CoreMapping.tar.gz Download (4.8 KB) - added by darinm 6 years ago.
source code and support files to reproduce bug

Change History

Changed 6 years ago by darinm

source code and support files to reproduce bug

Changed 6 years ago by simonmar

  • owner set to simonmar
  • difficulty set to Unknown
  • milestone set to 6.8.3

The code being run is this:

test = case reified of
         Left  err -> print err
         Right res -> GHC.printDump $ GHC.ppr res

The GHC package needs some initialisation before you can use it. Normally you would do this by calling GHC.newSession, but if you don't need a full Session you can call GHC.parseStaticFlags to initialise the static flags.

I'll make the error message a bit more informative.

Changed 6 years ago by simonmar

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

better error message added.

Note: See TracTickets for help on using tickets.