[GHC] #11172: Turning on optimisations produces Impossible case alternative

GHC ghc-devs at haskell.org
Mon Dec 7 16:10:23 UTC 2015


#11172: Turning on optimisations produces Impossible case alternative
-------------------------------------+-------------------------------------
           Reporter:  nh2            |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.0.1
          Component:  Compiler       |           Version:  7.10.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Runtime crash
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I believe I've found a bug that makes GHC generate the "Impossible case
 alternative" run-time crash with optimisations turned on (`-O`), which
 does not happen in ghci or without optimisations (`-O0`).

 Please see

   https://github.com/fpco/impossible-case-alternative-repro

 for a reproduction with GHC 7.10 and 7.8.

 What seems to happen here is that when `fun2` is inlined, the simplifier
 (or whatever component) decides that some `case` (I haven't figured out
 yet which one) is impossible; you can clearly see how it gets fixed in the
 Core when adding a `NOINLINE fun2` and compiling with `-ddump-simpl`. I
 believe this difference in inlining is also why `-O` makes a difference vs
 `-O0`.

 What certainly surprised me is that when replacing


 {{{
        (do p <- earlyExit <* error "bad"
            return p)
 }}}

 with

 {{{
        (earlyExit <* error "bad")
 }}}

 the error goes away as well.

 Note that I'm using some TemplateHaskell around that block; I'm wondering
 whether that somehow leads to an unfortunate interaction with the
 simpilifier.

 First thing I'd appreciate is somebody to tell me: Is this a real bug or
 something GHC allows itself to do? Since for most other run-time errors,
 GHC asks me to report a bug, but it doesn't do so for `Impossible case
 alternative`.

 I would have liked to make a smaller reproduction (currently it needs 2
 files and aeson as an external depencency), but if I shrink it any further
 the error goes away. So for now I hope that a 150 line repro in 2 files
 will do.

 We have reproduced this on Linux and Mac, but I'm quite confident that
 it's platform-independent.

 I'm setting the milestone for this to 8.0.1 because this is a problem that
 makes some real-world trouble for us, feel free to change back if that's
 inappropriate.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11172>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list