Ticket #1402 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

panic in GHC when building QuickCheck with optimization

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.7
Keywords: Cc: cdsmith@…
Operating System: Linux Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: spec003 Blocked By:
Blocking: Related Tickets:

Description

When building QuickCheck?, I get:

cdsmith@devtools:~/tmp/QuickCheck$ runhaskell Setup build
Preprocessing library QuickCheck-2.0...
Building QuickCheck-2.0...
Glasgow Haskell Compiler, Version 6.7.20070529, for Haskell 98, compiled by GHC                                                                                                                            version 6.7.20070529
Using package config file: /usr/local/lib/ghc-6.7.20070529/package.conf
wired-in package base mapped to base-2.1
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0
wired-in package template-haskell mapped to template-haskell-0.1
Hsc static flags: -static
*** Chasing dependencies:
Chasing modules from: Test.QuickCheck,Test.QuickCheck.Arbitrary,Test.QuickCheck.                                                                                                                           Function,Test.QuickCheck.Gen,Test.QuickCheck.Monadic,Test.QuickCheck.Property,Te                                                                                                                           st.QuickCheck.Test,Test.QuickCheck.Exception,Test.QuickCheck.Text
Stable obj: []
Stable BCO: []
Ready for upsweep
  [NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:28:15 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Gen,
         ms_imps = [Control.Monad.Reader, Control.Monad, System.Random]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:40 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Arbitrary,
         ms_imps = [Control.Monad, Data.List, System.Random, Data.Ratio,
                    Data.Char, Test.QuickCheck.Gen]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:39 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Exception,
         ms_imps = [Control.Exception]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:39 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Text,
         ms_imps = [Data.IORef, System.IO]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:40 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Property,
         ms_imps = [System.IO, Data.IORef, Control.Concurrent,
                    Test.QuickCheck.Exception, Test.QuickCheck.Text,
                    Test.QuickCheck.Arbitrary, Test.QuickCheck.Gen]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:40 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Test,
         ms_imps = [Data.List, Data.Char, System.Random,
                    Test.QuickCheck.Exception, Test.QuickCheck.Text,
                    Test.QuickCheck.Property, Test.QuickCheck.Gen]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:40 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Monadic,
         ms_imps = [System.IO.Unsafe, Control.Monad.ST, Control.Monad,
                    Test.QuickCheck.Arbitrary, Test.QuickCheck.Property,
                    Test.QuickCheck.Gen]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:40 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck.Function,
         ms_imps = [System.IO.Unsafe, Data.List, Data.IORef,
                    Test.QuickCheck.Property, Test.QuickCheck.Arbitrary,
                    Test.QuickCheck.Gen]
         ms_srcimps = []
      },
   NONREC
      ModSummary {
         ms_hs_date = Fri Jun  1 10:11:40 MDT 2007
         ms_mod = QuickCheck-2.0:Test.QuickCheck,
         ms_imps = [Test.QuickCheck.Test, Test.QuickCheck.Property,
                    Test.QuickCheck.Arbitrary, Test.QuickCheck.Gen]
         ms_srcimps = []
      }]
compile: input file Test/QuickCheck/Gen.hs
Created temporary directory: /tmp/ghc2049_0
*** Checking old interface for QuickCheck-2.0:Test.QuickCheck.Gen:
[1 of 9] Compiling Test.QuickCheck.Gen ( Test/QuickCheck/Gen.hs, dist/build/Test                                                                                                                           /QuickCheck/Gen.o )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 1180
*** Simplify:
    Result size = 803
    Result size = 789
    Result size = 789
*** Specialise:
*** Deleting temp files:
Deleting: /tmp/ghc2049_0/ghc2049_0.s
Warning: deleting non-existent /tmp/ghc2049_0/ghc2049_0.s
*** Deleting temp dirs:
Deleting: /tmp/ghc2049_0
ghc-6.7.20070529: panic! (the 'impossible' happened)
  (GHC version 6.7.20070529 for i386-unknown-linux):
        my_zipEqual
    []
    [random-1.0:System.Random.$f6{v r2X} [gid]]
    QuickCheck-2.0:Test.QuickCheck.Gen.choose{v r6H} [lid] [Just base:GHC.Base.I                                                                                                                           nt{(w) tc 3J}]
    \ (@ a{tv asq} [sk] :: base:GHC.Prim.*{(w) tc 34d}) ->
      (a_sIo{v} [lid] @ a{tv asq} [sk])
      `cast` (<pred>random-1.0:System.Random.Random{tc r33}
                      a{tv asq} [sk]
              -> (a{tv asq} [sk], a{tv asq} [sk])
              -> base:GHC.Prim.sym{(w) tc 34v}
                   ((QuickCheck-2.0:Test.QuickCheck.Gen.:CoGen{tc rfI})
                      a{tv asq} [sk])
              :: <pred>(random-1.0:System.Random.Random{tc r33}
                          a{tv asq} [sk]) =>
                       (a{tv asq} [sk], a{tv asq} [sk])
                       -> random-1.0:System.Random.StdGen{tc r35}
                       -> base:GHC.Base.Int{(w) tc 3J}
                       -> a{tv asq} [sk]
                         ~
                       (random-1.0:System.Random.Random{tc r33} a{tv asq} [sk])                                                                                                                            =>
                       (a{tv asq} [sk], a{tv asq} [sk])
                       -> <nt>QuickCheck-2.0:Test.QuickCheck.Gen.Gen{tc r76}
                            a{tv asq} [sk])

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

If I build with -Onot, the error does not occur.

cdsmith@devtools:~/tmp/QuickCheck$ uname -a
Linux devtools 2.4.27-2-k7 #1 Tue Aug 16 17:30:14 JST 2005 i686 GNU/Linux

The error occurs in:

-- | Generates a random element in the given inclusive range.
choose :: Random a => (a,a) -> Gen a
choose rng = MkGen (\r _ -> let (x,_) = randomR rng r in x)

The GHC version is one that I pulled from darcs head on the 29th of May. It does have one local modification, but in an unrelated part of the compiler (the GHCi banner patch I sent to the cvs-ghc list on 6/1/2007)

Attachments

qc.tar.gz Download (91.7 KB) - added by cdsmith@… 6 years ago.
tar of the directory that fails

Change History

Changed 6 years ago by simonpj

Dear cdsmith

We'd like to reproduce this. But darcs.haskell.org/packages/QuickCheck doesn't have Test.QuickCheck.Gen.

So, can you send us a repo case? Ideally, boiled down, but if you can't face that, then just a blob of files and build instructions.

If you put yourself in the cc field of this bug report, you'll see these updates. As it is, we have no way to contact you!

Simon

Changed 6 years ago by guest

  • cc cdsmith@… added

Changed 6 years ago by cdsmith@…

Hmm. It appears that I grabbed  http://darcs.haskell.org/QuickCheck/ instead of  http://darcs.haskell.org/packages/QuickCheck/. I don't know what the difference is.

I'll tar up the directory and attach it. I hope that's what you mean by a repo case.

Changed 6 years ago by cdsmith@…

tar of the directory that fails

Changed 6 years ago by simonpj

Excellent. I've boiled it down to a 3-line program that crashes the HEAD with -O

newtype Gen a = MkGen{ unGen :: Int -> a }

choose :: Eq a => a -> Gen a
choose n = MkGen (\r -> n)

oneof = choose (1::Int)

Need to investigate further, but this is progress.

Changed 6 years ago by simonpj

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

Fixed! Test is spec003

It was a bug in the specialiser.

Simon

Thu Jun 7 19:55:34 BST 2007 Lemmih <lemmih@…>

  • Fix Trac #1402: typo in specialiser

This patch fixes a plain bug in the specialiser (rhs_bndrs instead of rhs_ids) which made GHC crash in obscure cases.

It exposed a case in which we might not do all possible specialisation; see Note [Specialisation shape]. It's not an important case, but I've added a warning in DEBUG mode.

Trac #1402. Test is spec003.hs

Note: See TracTickets for help on using tickets.