[GHC] #11027: GHC API panic (evaluated the place holder for a PostTcType)

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Keywords: undefined, | Operating System: Linux place holder, posttctype | Architecture: x86_64 | Type of failure: Runtime crash (amd64) | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The same code that works for GHC 7.10.2 blows up on GHC 7.8.4, with errors like {{{ test/ArgonSpec.hs:104: (best-effort) 6) Argon.analyze accounts for && operator uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): fixity Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug ) test/ArgonSpec.hs:106: (best-effort) 7) Argon.analyze counts everything in a real example uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): Evaluated the place holder for a PostTcType Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug ) }}} The responsible module is [https://github.com/rubik/argon/blob/master/src/Argon/Visitor.hs] and in particular (I think): {{{ visitExp :: Exp -> Int visitExp (GHC.HsIf {}) = 1 visitExp (GHC.HsMultiIf _ alts) = length alts - 1 visitExp (GHC.HsLamCase _ alts) = length (GHC.mg_alts alts) - 1 visitExp (GHC.HsCase _ alts) = length (GHC.mg_alts alts) - 1 visitExp _ = 0 visitOp :: Exp -> Int visitOp (GHC.OpApp _ (GHC.L _ (GHC.HsVar op)) _ _) = case getName op of "||" -> 1 "&&" -> 1 _ -> 0 visitOp _ = 0 }}} somehow, even if I use wildcards, the first arguments of the type constructors gets evaluated and since it's undefined GHC crashes. What am I supposed to do? The documentation does not say anything on the matter. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rubik): * cc: simonpj (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I'd ask Alan Zimmerman. Certainly if you write a wildcard in a pattern match GHC won't evaluate that field in a pattern match: {{{ f (C _ x) = ... }}} the `_` argument of `C` will not be evaluated by `f`. (It might be evaluated for some other reason.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by rubik: Old description:
The same code that works for GHC 7.10.2 blows up on GHC 7.8.4, with errors like {{{ test/ArgonSpec.hs:104: (best-effort) 6) Argon.analyze accounts for && operator uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): fixity
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug )
test/ArgonSpec.hs:106: (best-effort) 7) Argon.analyze counts everything in a real example uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): Evaluated the place holder for a PostTcType
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug ) }}}
The responsible module is [https://github.com/rubik/argon/blob/master/src/Argon/Visitor.hs] and in particular (I think): {{{ visitExp :: Exp -> Int visitExp (GHC.HsIf {}) = 1 visitExp (GHC.HsMultiIf _ alts) = length alts - 1 visitExp (GHC.HsLamCase _ alts) = length (GHC.mg_alts alts) - 1 visitExp (GHC.HsCase _ alts) = length (GHC.mg_alts alts) - 1 visitExp _ = 0
visitOp :: Exp -> Int visitOp (GHC.OpApp _ (GHC.L _ (GHC.HsVar op)) _ _) = case getName op of "||" -> 1 "&&" -> 1 _ -> 0 visitOp _ = 0 }}} somehow, even if I use wildcards, the first arguments of the type constructors gets evaluated and since it's undefined GHC crashes. What am I supposed to do? The documentation does not say anything on the matter.
New description: The same code that works for GHC 7.10.2 blows up on GHC 7.8.4, with errors like {{{ test/ArgonSpec.hs:104: (best-effort) 6) Argon.analyze accounts for && operator uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): fixity Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug ) test/ArgonSpec.hs:106: (best-effort) 7) Argon.analyze counts everything in a real example uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): Evaluated the place holder for a PostTcType Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug ) }}} The responsible module is [https://github.com/rubik/argon/blob/ghc-7.8/src/Argon/Visitor.hs] and in particular (I think): {{{ visitExp :: Exp -> Int visitExp (GHC.HsIf {}) = 1 visitExp (GHC.HsMultiIf _ alts) = length alts - 1 visitExp (GHC.HsLamCase _ alts) = length (GHC.mg_alts alts) - 1 visitExp (GHC.HsCase _ alts) = length (GHC.mg_alts alts) - 1 visitExp _ = 0 visitOp :: Exp -> Int visitOp (GHC.OpApp _ (GHC.L _ (GHC.HsVar op)) _ _) = case getName op of "||" -> 1 "&&" -> 1 _ -> 0 visitOp _ = 0 }}} somehow, even if I use wildcards, the first arguments of the type constructors gets evaluated and since it's undefined GHC crashes. What am I supposed to do? The documentation does not say anything on the matter. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rubik): * cc: alanz (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): I think the problem is the generic traversal on line 27. {{{ getBinds :: (Data from, Typeable from) => from -> [Function] getBinds = everything (++) $ mkQ [] visit where visit fun@(GHC.FunBind {}) = [fun] visit _ = [] }}} It is not safe to do generic traversals on the GHC 7.8 AST due to the reason you encountered! There are landmines. You can use ghc-syb-utils if you want to also support 7.8. In future, triggering panics when using the API isn't usually a bug in GHC. Alan and I will be happy to help you on #haskell-refactorer if you have any more questions. https://hackage.haskell.org/package/ghc-syb-utils-0.2.3/docs/GHC-SYB- Utils.html -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rubik): Wonderful, thank you! Using {{{everythingStaged}}} solves the problem. I'll check out #haskell-refactorer. In the future I won't open bugs for these things. But being the first time it happened, and because the error message was telling me to file a bug, I opened a ticket. Now I know better :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: fixed | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rubik): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: closed => new * resolution: fixed => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11027: GHC API panic (evaluated the place holder for a PostTcType) -------------------------------------+------------------------------------- Reporter: rubik | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHC API | Version: 7.8.4 Resolution: invalid | Keywords: undefined, | place holder, posttctype Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => invalid -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11027#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC