Ticket #3118 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

ghc: panic! (the 'impossible' happened): Missing alternative

Reported by: calvins Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Difficulty: Unknown
Test Case: simplCore/should_compiler/T3118 Blocked By:
Blocking: Related Tickets:

Description

When I include the -auto-all option (in addition to -prof) on the entry for Main in my Cabal file, I get the ghc panic message below. Full compile output attached.

[10 of 10] Compiling Main             ( Rdf4hParseMain.hs, dist/build/rdf4h/rdf4h-tmp/Main.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 6.10.1 for x86_64-unknown-linux):
	Missing alternative
    main:Main.OutputFormat{d r16LZ}
    (main:Main.Help{d r16M9}, [], lvl_s17ar{v} [lid])
    (main:Main.Debug{d r16M7}, [], lvl_s17as{v} [lid])
    (main:Main.Version{d r16M5}, [], lvl_s17at{v} [lid])

To reproduce the bug, check out a tagged version of the code using:

darcs get -t 'ghc bug report'  http://protempore.net/rdf4h

And then edit the cabal file by adding "-prof -auto-all" to the library and main entries, and you should see what I see above if it's reproducible. It compiles fine if the options are only added to the library block, and it compiles fine if '-prof' but not '-auto-all' is added to the executable block, but fails when '-prof' and '-auto-all' are both added to the executable block.

Attachments

compile-output-v3.out Download (47.7 KB) - added by calvins 4 years ago.
Compiler output (-v3)

Change History

Changed 4 years ago by calvins

Compiler output (-v3)

Changed 4 years ago by simonpj

  • difficulty set to Unknown

Very odd. This happens in the situation where GHC's optimiser encounters

   case (OutputFormat ...) of 
      Help ->
      Debug ->
      Version ->

with no other alternatives, not even a default. That can't happen in source code, since GHC adds an invisible default, but it can happen internally if the optimiser proves that no other alternatives can happen. But here another alternative does! That's a bug. Needs investigation.

Simon

Changed 4 years ago by simonpj

I don't know whether this is anything to do with your problem, but I can't get started:

bash-3.2$ cabal install
Resolving dependencies...
cabal: dependencies conflict: HTTP-4000.0.4 requires parsec ==2.1.0.1 however
parsec-2.1.0.1 was excluded because rdf4h-0.7 requires parsec >=3 && >=3
bash-3.2$ 

Seems that your package dependencies aren't right.

Simon

Changed 4 years ago by calvins

Hmmm, that's odd. The  cabal file for HTTP-4004.0.4 doesn't list a version for parsec, and my package manager (on Gentoo) does not list a required version for parsec either.

I will try uninstalling things and reinstalling using cabal-install rather than my package manager, and will report back.

Changed 4 years ago by calvins

I'm unable to install 'cabal install' on a clean Ubuntu install because it doesn't seem to work with Parsec 3, which my library required.

Are you able to compile with plain cabal? I checked the cabal conf files for the dependencies and verified that none of them specify Parsec 2.1.0.1. They all compile fine for me against Parsec-3.0.0 as long as I use 'runhaskell Setup ...' to compile and install rather than 'cabal install'.

Changed 4 years ago by simonpj

  • status changed from new to closed
  • testcase set to simplCore/should_compiler/T3118
  • resolution set to fixed

Aha. We managed to reproduce it. Fixed by this

Thu Apr  2 16:28:34 BST 2009  simonpj@microsoft.com
  * Fix Trac #3118: missing alternative
  
  This patch fixes a rather obscure bug, whereby it's possible
  for (case C a b of <alts>) to have altenatives that do not inclue
  (C a b)!  See Note [Unreachable code] in CoreUtils.
  

    M ./compiler/basicTypes/MkId.lhs -2 +6
    M ./compiler/coreSyn/CoreUtils.lhs -11 +42
    M ./compiler/simplCore/Simplify.lhs -27 +28
    M ./compiler/specialise/SpecConstr.lhs -1 +3

Simon

Note: See TracTickets for help on using tickets.