[GHC] #8037: GHC panic when compiling unsafeCoerce

#8037: GHC panic when compiling unsafeCoerce ---------------------------+------------------------------------------------ Reporter: ghc@… | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ The GHC compiler crashes on the following program. {{{ module Test where import Unsafe.Coerce import Graphics.Rendering.OpenGL (color, Color3, GLdouble) data D4 = D4 Double Double Double Double crash :: D4 -> IO () crash c = color (invalidCast c) invalidCast :: D4 -> Color3 GLdouble invalidCast = unsafeCoerce }}} With the following output: {{{ [1 of 1] Compiling Test ( Test.hs, Test.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.6.1 for x86_64-apple-darwin): cgLookupPanic (probably invalid Core; try -dcore-lint) ww_s28U{v} [lid] static binds for: local binds for: }}} I've made several attempts to make the input program smaller, but all modifications will result in successful compilation. The cast is invalid but should produce an runtime error, not a compile time error. Changes I made that somehow prevent this bug from appearing: - Changing the `crash` functions into point free style `color . invalidCast`. - Decreasing the amount of doubles in the `D4` datatype. - Inlining the exact definitions from the OpenGL package. - Using the `print` function instead of the `color` function. (btw, I know I shouldn't use unsafeCoerce) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8037 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8037: GHC panic when compiling unsafeCoerce ---------------------------------+------------------------------------------ Reporter: ghc@… | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonpj): * difficulty: => Unknown Comment: Can you give a test case that doesn't depend on `OpenGL`? Eg make a stub module that has the relevant bits of `OpenGL` in it? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8037#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8037: GHC panic when compiling unsafeCoerce ---------------------------------+------------------------------------------ Reporter: ghc@… | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by ghc@…): I tried really hard to do this, but that didn't work out. Every change I made the program compile again. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8037#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8037: GHC panic when compiling unsafeCoerce ---------------------------------+------------------------------------------ Reporter: ghc@… | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Keywords: | Os: MacOS X Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Comment(by monoidal): I can't reproduce on Linux, GHC 7.6.3, OpenGL-2.6 or OpenGL-2.8. What version of OpenGL do you use? Also what happens when you compile with -dcore-lint? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8037#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC