[GHC] #15108: Panic: collectNBinders

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.4.2 Keywords: panic | Operating System: Linux collectNBinders | Architecture: | Type of failure: Compile-time Unknown/Multiple | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- GHC 8.4.2 panics with the error message `collectNBinders`, when compiling with profiling. This is a very similar bug to #15002, but although #15002 is fixed in 8.4.2, this panic persists. Steps to reproduce: `stack.yaml`: {{{ resolver: nightly-2018-04-30 }}} `bug.cabal`: {{{ name: bug version: 0.1.0.0 build-type: Simple cabal-version: >=1.10 library build-depends: base default-language: Haskell2010 executable bug main-is: Main.hs build-depends: base , bug default-language: Haskell2010 }}} `Main.hs`: {{{ module Main where main :: IO () main = do _ <- return $ getInt Circle return () newtype MyInt = MyInt Int data Shape = Circle | Square getInt :: Shape -> MyInt getInt sh = case sh of Circle -> let (MyInt i) = MyInt 3 in myInt i Square -> let (MyInt i) = MyInt 2 in myInt i where myInt = MyInt }}} Then run: {{{ $ stack ghc -- --version The Glorious Glasgow Haskell Compilation System, version 8.4.2 $ stack build --profile bug-0.1.0.0: build (lib + exe) Preprocessing library for bug-0.1.0.0.. Building library for bug-0.1.0.0.. Preprocessing executable 'bug' for bug-0.1.0.0.. Building executable 'bug' for bug-0.1.0.0.. [1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64 -linux-tinfo6-nopie/Cabal-2.2.0.1/build/bug/bug-tmp/Main.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.4.2 for x86_64-unknown-linux): collectNBinders 1 Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreSyn.hs:2025:25 in ghc:CoreSyn Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug -- While building custom Setup.hs for package bug-0.1.0.0 using: /usr/local/home/<USER>/.stack/setup-exe-cache/x86_64-linux- tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.2 --builddir=.stack- work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.2.0.1 build lib:bug exe:bug --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always" Process exited with code: ExitFailure 1 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.4.2 Resolution: | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by cdisselkoen: Old description:
GHC 8.4.2 panics with the error message `collectNBinders`, when compiling with profiling. This is a very similar bug to #15002, but although #15002 is fixed in 8.4.2, this panic persists.
Steps to reproduce:
`stack.yaml`: {{{ resolver: nightly-2018-04-30 }}}
`bug.cabal`: {{{ name: bug version: 0.1.0.0 build-type: Simple cabal-version: >=1.10
library build-depends: base default-language: Haskell2010
executable bug main-is: Main.hs build-depends: base , bug default-language: Haskell2010 }}}
`Main.hs`: {{{ module Main where
main :: IO () main = do _ <- return $ getInt Circle return ()
newtype MyInt = MyInt Int
data Shape = Circle | Square
getInt :: Shape -> MyInt getInt sh = case sh of Circle -> let (MyInt i) = MyInt 3 in myInt i Square -> let (MyInt i) = MyInt 2 in myInt i where myInt = MyInt }}}
Then run: {{{ $ stack ghc -- --version The Glorious Glasgow Haskell Compilation System, version 8.4.2
$ stack build --profile bug-0.1.0.0: build (lib + exe) Preprocessing library for bug-0.1.0.0.. Building library for bug-0.1.0.0.. Preprocessing executable 'bug' for bug-0.1.0.0.. Building executable 'bug' for bug-0.1.0.0.. [1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64 -linux-tinfo6-nopie/Cabal-2.2.0.1/build/bug/bug-tmp/Main.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.4.2 for x86_64-unknown-linux): collectNBinders 1 Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreSyn.hs:2025:25 in ghc:CoreSyn
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
-- While building custom Setup.hs for package bug-0.1.0.0 using: /usr/local/home/<USER>/.stack/setup-exe-cache/x86_64-linux- tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.2 --builddir=.stack- work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.2.0.1 build lib:bug exe:bug --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always" Process exited with code: ExitFailure 1 }}}
New description: GHC 8.4.2 panics with the error message `collectNBinders`, when compiling with profiling. This is a very similar bug to #15002, but although #15002 is fixed in 8.4.2, this panic persists. Steps to reproduce: `stack.yaml`: {{{ resolver: nightly-2018-04-30 }}} `bug.cabal`: {{{ name: bug version: 0.1.0.0 build-type: Simple cabal-version: >=1.10 executable bug main-is: Main.hs build-depends: base default-language: Haskell2010 }}} `Main.hs`: {{{ module Main where main :: IO () main = do _ <- return $ getInt Circle return () newtype MyInt = MyInt Int data Shape = Circle | Square getInt :: Shape -> MyInt getInt sh = case sh of Circle -> let (MyInt i) = MyInt 3 in myInt i Square -> let (MyInt i) = MyInt 2 in myInt i where myInt = MyInt }}} Then run: {{{ $ stack ghc -- --version The Glorious Glasgow Haskell Compilation System, version 8.4.2 $ stack build --profile bug-0.1.0.0: build (lib + exe) Preprocessing library for bug-0.1.0.0.. Building library for bug-0.1.0.0.. Preprocessing executable 'bug' for bug-0.1.0.0.. Building executable 'bug' for bug-0.1.0.0.. [1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64 -linux-tinfo6-nopie/Cabal-2.2.0.1/build/bug/bug-tmp/Main.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.4.2 for x86_64-unknown-linux): collectNBinders 1 Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreSyn.hs:2025:25 in ghc:CoreSyn Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug -- While building custom Setup.hs for package bug-0.1.0.0 using: /usr/local/home/<USER>/.stack/setup-exe-cache/x86_64-linux- tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.2 --builddir=.stack- work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.2.0.1 build lib:bug exe:bug --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always" Process exited with code: ExitFailure 1 }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.4.2 Resolution: | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by cdisselkoen: Old description:
GHC 8.4.2 panics with the error message `collectNBinders`, when compiling with profiling. This is a very similar bug to #15002, but although #15002 is fixed in 8.4.2, this panic persists.
Steps to reproduce:
`stack.yaml`: {{{ resolver: nightly-2018-04-30 }}}
`bug.cabal`: {{{ name: bug version: 0.1.0.0 build-type: Simple cabal-version: >=1.10
executable bug main-is: Main.hs build-depends: base default-language: Haskell2010 }}}
`Main.hs`: {{{ module Main where
main :: IO () main = do _ <- return $ getInt Circle return ()
newtype MyInt = MyInt Int
data Shape = Circle | Square
getInt :: Shape -> MyInt getInt sh = case sh of Circle -> let (MyInt i) = MyInt 3 in myInt i Square -> let (MyInt i) = MyInt 2 in myInt i where myInt = MyInt }}}
Then run: {{{ $ stack ghc -- --version The Glorious Glasgow Haskell Compilation System, version 8.4.2
$ stack build --profile bug-0.1.0.0: build (lib + exe) Preprocessing library for bug-0.1.0.0.. Building library for bug-0.1.0.0.. Preprocessing executable 'bug' for bug-0.1.0.0.. Building executable 'bug' for bug-0.1.0.0.. [1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64 -linux-tinfo6-nopie/Cabal-2.2.0.1/build/bug/bug-tmp/Main.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.4.2 for x86_64-unknown-linux): collectNBinders 1 Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreSyn.hs:2025:25 in ghc:CoreSyn
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
-- While building custom Setup.hs for package bug-0.1.0.0 using: /usr/local/home/<USER>/.stack/setup-exe-cache/x86_64-linux- tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.2 --builddir=.stack- work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.2.0.1 build lib:bug exe:bug --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always" Process exited with code: ExitFailure 1 }}}
New description: GHC 8.4.2 panics with the error message `collectNBinders`, when compiling with profiling. This is a very similar bug to #15002, but although #15002 is fixed in 8.4.2, this panic persists. Steps to reproduce: `stack.yaml`: {{{ resolver: nightly-2018-04-30 }}} `bug.cabal`: {{{ name: bug version: 0.1.0.0 build-type: Simple cabal-version: >=1.10 executable bug main-is: Main.hs build-depends: base default-language: Haskell2010 }}} `Main.hs`: {{{ module Main where main :: IO () main = do _ <- return $ getInt Circle return () newtype MyInt = MyInt Int data Shape = Circle | Square getInt :: Shape -> MyInt getInt sh = case sh of Circle -> let (MyInt i) = MyInt 3 in myInt i Square -> let (MyInt i) = MyInt 2 in myInt i where myInt = MyInt }}} Then run: {{{ $ stack ghc -- --version The Glorious Glasgow Haskell Compilation System, version 8.4.2 $ stack build --profile bug-0.1.0.0: configure (exe) Configuring bug-0.1.0.0... bug-0.1.0.0: build (exe) Preprocessing executable 'bug' for bug-0.1.0.0.. Building executable 'bug' for bug-0.1.0.0.. [1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64 -linux-tinfo6-nopie/Cabal-2.2.0.1/build/bug/bug-tmp/Main.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.4.2 for x86_64-unknown-linux): collectNBinders 1 Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreSyn.hs:2025:25 in ghc:CoreSyn Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug -- While building custom Setup.hs for package bug-0.1.0.0 using: /usr/local/home/cdisselk/.stack/setup-exe-cache/x86_64-linux- tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.2 --builddir=.stack- work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.2.0.1 build exe:bug --ghc- options " -ddump-hi -ddump-to-file -fdiagnostics-color=always" Process exited with code: ExitFailure 1 }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.4.2 Resolution: | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by cdisselkoen): Note: also reproduces with GHC 8.2.2 (stackage `lts-11.7`). {{{ $ stack ghc -- --version The Glorious Glasgow Haskell Compilation System, version 8.2.2 $ stack build --profile bug-0.1.0.0: configure (exe) Configuring bug-0.1.0.0... bug-0.1.0.0: build (exe) Preprocessing executable 'bug' for bug-0.1.0.0.. Building executable 'bug' for bug-0.1.0.0.. [1 of 1] Compiling Main ( Main.hs, .stack-work/dist/x86_64 -linux-tinfo6-nopie/Cabal-2.0.1.0/build/bug/bug-tmp/Main.p_o ) ghc: panic! (the 'impossible' happened) (GHC version 8.2.2 for x86_64-unknown-linux): collectNBinders 1 Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/coreSyn/CoreSyn.hs:1997:25 in ghc:CoreSyn Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug -- While building custom Setup.hs for package bug-0.1.0.0 using: /usr/local/home/cdisselk/.stack/setup-exe-cache/x86_64-linux- tinfo6-nopie/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack- work/dist/x86_64-linux-tinfo6-nopie/Cabal-2.0.1.0 build exe:bug --ghc- options " -ddump-hi -ddump-to-file -fdiagnostics-color=always" Process exited with code: ExitFailure 1 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders
-------------------------------------+-------------------------------------
Reporter: cdisselkoen | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Profiling | Version: 8.4.2
Resolution: | Keywords: panic
| collectNBinders
Operating System: Linux | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Joachim Breitner

#15108: Panic: collectNBinders
-------------------------------------+-------------------------------------
Reporter: cdisselkoen | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Profiling | Version: 8.4.2
Resolution: | Keywords: panic
| collectNBinders
Operating System: Linux | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
Thanks for the nice test case, I added it to the test suite.
JFTR, this can be easily reproduced without stack or GHC:
{{{
~/build/haskell/ghc-master $ ./inplace/bin/ghc-stage2
testsuite/tests/profiling/should_compile/T15108.hs -prof -fprof-auto
-dcore-lint
[1 of 1] Compiling Main (
testsuite/tests/profiling/should_compile/T15108.hs,
testsuite/tests/profiling/should_compile/T15108.o )
*** Core Lint errors : in result of Desugar (after optimization) ***
testsuite/tests/profiling/should_compile/T15108.hs:22:7: warning:
[RHS of myInt_aVZ :: Int -> MyInt]
Join point has too few lambdas
Join var: myInt_aVZ
Join arity: 1
Number of lambdas: 0
Rhs = scctick

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.4.2 Resolution: | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I'm on this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders
-------------------------------------+-------------------------------------
Reporter: cdisselkoen | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Profiling | Version: 8.4.2
Resolution: | Keywords: panic
| collectNBinders
Operating System: Linux | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#15108: Panic: collectNBinders
-------------------------------------+-------------------------------------
Reporter: cdisselkoen | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Profiling | Version: 8.4.2
Resolution: | Keywords: panic
| collectNBinders
Operating System: Linux | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Profiling | Version: 8.4.2 Resolution: fixed | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed * milestone: => 8.6.1 Comment: OK, fixed. Thanks for a great report. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Profiling | Version: 8.4.2 Resolution: fixed | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): Have you considered adding {{{ | JoinNonRec v [v] (Expr v) | JoinRec [(v, [v], Expr v)] }}} to `Bind v`? It seems that a great lot of code has to zoom past the binders of a join point, causing bugs. With these constructors, one would be forced to handle them properly – and code that does not need to pay attention can use a pattern synonym that recreates the original view. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Profiling | Version: 8.4.2 Resolution: fixed | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I suppose we could, but a key aspect of the current join points is that their semantics is exactly that of let-bindings; and often code (e.g. strictness analysis) can work uniformly for both. Yes, there are many ways in which we could change the representation. E.g. maybe `Lam` should take a list of binders, or `App` should take a list of arguments. But my instinct is that you save code in some places and lose it in others. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15108: Panic: collectNBinders -------------------------------------+------------------------------------- Reporter: cdisselkoen | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Profiling | Version: 8.4.2 Resolution: fixed | Keywords: panic | collectNBinders Operating System: Linux | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): Yeah, it’d probably amount to shifting boxes around without making any new space :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15108#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC