Ticket #5684 (closed bug: fixed)

Opened 18 months ago

Last modified 17 months ago

ghc: panic! (the 'impossible' happened) (ghc 7.2.2)

Reported by: selinger Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.2.1
Keywords: Cc: selinger@…, dimitris@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Difficulty:
Test Case: typecheck/should_fail/T5684.hs Blocked By:
Blocking: Related Tickets:

Description

I seem to have found an "impossible" bug, and I am reporting it here as instructed.

The bug can be reliably reproduced with gcc-7.2.2. I can reproduce this bug with both the binaries from the generic 64-bit linux distribution ghc-7.2.2-x86_64-unknown-linux.tar.bz2, and the generic 32-bit linux distribution ghc-7.2.2-i386-unknown-linux.tar.bz2 (these were the only two I tried).

Unfortunately, I can't publicly send the source code, because it is part of a confidential project. However, if this bug is not yet known/fixed, I can probably produce a minimal and "sanitized" example.

Here is what I get:

ghc  -o qcs Main.hs
[ 9 of 10] Compiling BWT              ( BWT.hs, BWT.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.2.2 for i386-unknown-linux):
        Unexpected given!

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

make: *** [qcs] Error 1

Please let me know how I can proceed to collect more information on this bug! Thanks, -- Peter

Attachments

Bug.hs Download (1.2 KB) - added by selinger 17 months ago.
reproduces ghc: panic! (the 'impossible' happened) in ghc 7.2.2

Change History

Changed 17 months ago by selinger

reproduces ghc: panic! (the 'impossible' happened) in ghc 7.2.2

Changed 17 months ago by selinger

  • cc selinger@… added
  • failure changed from None/Unknown to Compile-time crash
  • summary changed from ghc: panic! (the 'impossible' happened) to ghc: panic! (the 'impossible' happened) (ghc 7.2.2)

I attached a file that reproduces this bug. When compiling this file with "ghc Bug.hs", using ghc 7.2.2, I reproducibly obtain the error:

ghc: panic! (the 'impossible' happened)
  (GHC version 7.2.2 for x86_64-unknown-linux):
        Unexpected given!

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

The file itself is nonsense, and in fact contains some type errors. However, it shouldn't kill the compiler.

Changed 17 months ago by dimitris

  • cc dimitris@… added

OK in HEAD it seems the panic has gone but the file has type errors. Is the following what you expected?:

/home/dimitris/extra-investigations/Bug.hs:49:22:
    Couldn't match type `[]' with `(->) Int'
    When using functional dependencies to combine
      Myclass [a] [qa] [ca],
        arising from the dependency `a -> qa'
        in the instance declaration at /home/dimitris/extra-investigations/Bug.hs:16:10
      Myclass [Bool] (Int -> Int) cb,
        arising from a use of `fun1'
        at /home/dimitris/extra-investigations/Bug.hs:49:22-25
    In the expression: fun1 (fun8 5) (a, b, False)
    In a pattern binding: (a', b', m') = fun1 (fun8 5) (a, b, False)
dimitris@cam-04-unx:/64playpen/dimitris/GHC-HEAD/ghc$ 

Changed 17 months ago by selinger

Yes, the type error is about right. Were you able to reproduce this in 7.2.2? The bug seems to be unstable, i.e., small changes in the source code make it go away. So it may be okay in HEAD because whatever the problem was has been fixed (which would be great), or because HEAD compiles some things in a slightly different order (in which case the bug may still be present, and may just not manifest with this particular example).

Changed 17 months ago by dimitris

  • status changed from new to closed
  • testcase set to typecheck/should_fail/T5684.hs
  • resolution set to fixed

Thanks for the feedback. There were two things wrong in 7.2.1:

  • An assertion was just false because of a broken invariant
  • But, the assertion was hidden under a thunk and got triggered not at the right place, potentially under random poking from who-knows-who.

Now, in HEAD by construction this invariant is true (so the real bug you observed no longer manifests there). But the assertion is still there so I did push a patch that makes the assertion trigger aggressively.

The test is in typecheck/should_fail/T5684.hs and the comments in that test describe the problem in more technical terms.

The relevant commit is:

commit bd13338da1649600b6a63ae7cbf60a35575940dc Author: Dimitrios Vytiniotis <dimitris@…> Date: Thu Dec 15 14:18:31 2011 +0000

Exposing a useful assertion which was hidden inside a lazyness cloud.

Note: See TracTickets for help on using tickets.