Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5045 closed bug (fixed)

"panic! (the 'impossible' happened)" compiling code using arrows and elimReader (test case included)

Reported by: josh Owned by: simonpj
Priority: high Milestone: 7.2.1
Component: Compiler Version: 7.0.2
Keywords: Cc: jamey@…, william.knop.nospam@…
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case: ghci/scripts/T5045
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


In trying to debug a different issue, I ran ghci on one of the modules in Serialist, and encountered a ghc panic. I managed to reduce it down to the following minimal test case:

{-# LANGUAGE Arrows #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}

import Control.Arrow
import Control.Arrow.Transformer.Reader

newtype ByteString = FakeByteString String

pathInfo :: Monad m => m String
pathInfo = undefined

requestMethod :: Monad m => m String
requestMethod = undefined

getInputsFPS :: Monad m => m [(String, ByteString)]
getInputsFPS = undefined

class HTTPRequest r s | r -> s where
    httpGetPath :: r -> String
    httpSetPath :: r -> String -> r
    httpGetMethod :: r -> String
    httpGetInputs :: r -> [(String, s)]

data CGIDispatch = CGIDispatch {
    dispatchPath :: String,
    dispatchMethod :: String,
    dispatchInputs :: [(String, ByteString)]

instance HTTPRequest CGIDispatch ByteString where
    httpGetPath = dispatchPath
    httpSetPath r s = r { dispatchPath = s }
    httpGetMethod = dispatchMethod
    httpGetInputs = dispatchInputs

runDispatch :: (Arrow a, ArrowAddReader CGIDispatch a a', Monad m) => a b c -> m (a' b c)
runDispatch a = do
    dispatchPath <- pathInfo
    dispatchMethod <- requestMethod
    dispatchInputs <- getInputsFPS
    return $ proc b -> (| elimReader (a -< b) |) CGIDispatch { .. }

Running "ghci TestCase.hs" produces this panic:

GHCi, version 7.0.2:  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( TestCase.hs, interpreted )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.0.2 for x86_64-unknown-linux):
    (|/\(@ a{tv av7} [sk]).
      ((arrows-{v rg4} [gid[ClassOp]])
       @ main:Main.CGIDispatch{tc rot}
       @ a{tv auK} [sk]
       @ a'{tv auL} [sk]
         $dArrowAddReader{v ava} [lid])
      @ a{tv av7} [sk]
      @ c{tv auO} [sk]
        ((a{v ap8} [lid] -< b{v apc} [lid]))|)

Please report this as a GHC bug:


Change History (7)

comment:1 Changed 9 years ago by altaic

Cc: william.knop.nospam@… added

On my HEAD build (OS X 10.6.6 x86_64), several arrow tests in the testsuite are also failing with panics involving addTickHsExpr:

  • arrowapply4(hpc)
  • arrowcase1(hpc)
  • arrowform1(hpc)
  • T3822(hpc)
  • T3822(ghci)

I can provide more verbose info if anyone's interested.

HEAD builds of x86_64 OS X are looking pretty good these days-- yesterday, 65 tests were failing in a full testsuite run, and today only 29. Most of those left are pretty obviously related; I suspect there are only a few real bugs left.

comment:2 Changed 9 years ago by simonpj

I have a patch for this in my tree. Waiting for the git switchover to complete.

comment:3 Changed 9 years ago by

Just FYI, the same five as reported by altaic above failed two days ago in HEAD's testsuite, in 7.0.3's testsuite run today, T3822(ghci) passed, the other four panicked.

comment:4 Changed 9 years ago by

Just to make sure: the patch is not yet in, so today's HEAD panicking on those is still to be expected?

comment:5 Changed 9 years ago by igloo

Milestone: 7.2.1
Owner: set to simonpj
Priority: normalhigh

comment:6 Changed 9 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: ghci/scripts/T5045

Missing case in the HPC code

commit 5af7fb4ffe4672dbc9cf34100ea311eb60981fe8
Author: simonpj <>
Date:   Tue Apr 19 13:33:09 2011 +0100

    Fix Trac #5045: add ticks to HsArrForms
    I don't know why these were left out.  I did the obvious
    thing... I hope it's right!

 compiler/deSugar/Coverage.lhs |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)


comment:7 Changed 9 years ago by ross@…

commit 10801b5568a8777dca5e42cca0b9cf5520d36763 Author: Ross Paterson <ross@…> Date: Wed Jun 29 18:50:48 2011 +0100

Fix #5045 properly

In arrow commands, the function position in an application (HsApp) is a command, not an expression.

Note: See TracTickets for help on using tickets.