[GHC] #16076: Internal compiler error when instance uses FFI function and defining other instance of the same class through Template Haskell

#16076: Internal compiler error when instance uses FFI function and defining other instance of the same class through Template Haskell -------------------------------------+------------------------------------- Reporter: | Owner: (none) radekchannable | Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.4 Keywords: | 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: -------------------------------------+------------------------------------- When one module defines an FFI function and uses it in an instance, and a Template Haskell function to derive an instance of the same class, using the function in another module causes GHC to crash, complaining it cannot find the FFI function. See the attached modules for an example. Use the following command to trigger the bug (ensure template-haskell is available): {{{ $ ghc Bar.hs [1 of 2] Compiling Foo ( Foo.hs, Foo.o ) [2 of 2] Compiling Bar ( Bar.hs, Bar.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.4.4 for x86_64-unknown-linux): Loading temp shared object failed: /tmp/ghc13955_0/libghc_6.so: undefined symbol: showFoo Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16076 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16076: Internal compiler error when instance uses FFI function and defining other instance of the same class through Template Haskell -------------------------------------+------------------------------------- Reporter: radekchannable | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.4 Resolution: | Keywords: 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 radekchannable): * Attachment "Foo.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16076 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16076: Internal compiler error when instance uses FFI function and defining other instance of the same class through Template Haskell -------------------------------------+------------------------------------- Reporter: radekchannable | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.4 Resolution: | Keywords: 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 radekchannable): * Attachment "Bar.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16076 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16076: Internal compiler error when instance uses FFI function and defining other instance of the same class through Template Haskell -------------------------------------+------------------------------------- Reporter: radekchannable | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.4 Resolution: | Keywords: 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 quasicomputational): I think the primary problem here is the error message. To run the TH code, GHC is trying to call the `showFoo` symbol that you've promised exists (with the FFI declaration) and, as it doesn't actually exist, it's failing to do so. That's manifesting as the GHCi linker error you're seeing. I've got confused and gone on a minor wild goose chase for a GHC bug because of this message myself. I wonder if the linker can be improved and give a better error here... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16076#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16076: Internal compiler error when instance uses FFI function and defining other instance of the same class through Template Haskell -------------------------------------+------------------------------------- Reporter: radekchannable | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.4 Resolution: | Keywords: 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 radekchannable): But there is no reason for it to call the showFoo function; its result is not used in any Template Haskell code. This would be a rather arbitrary limitation; not being able to define instances using Template Haskell just because an FFI function was declared in some module somewhere. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16076#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC