Opened 5 years ago

Closed 5 years ago

#5684 closed bug (fixed)

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 Test Case: typecheck/should_fail/T5684.hs
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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:

make: *** [qcs] Error 1

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

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by selinger

Attachment: Bug.hs added

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

comment:1 Changed 5 years ago by selinger

Cc: selinger@… added
Summary: ghc: panic! (the 'impossible' happened)ghc: panic! (the 'impossible' happened) (ghc 7.2.2)
Type of failure: None/UnknownCompile-time crash

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:

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

comment:2 Changed 5 years 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?:

    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)

comment:3 Changed 5 years 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).

comment:4 Changed 5 years ago by dimitris

Resolution: fixed
Status: newclosed
Test Case: typecheck/should_fail/T5684.hs

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.