[GHC] #9274: GHC panic with UnliftedFFITypes+CApiFFI

#9274: GHC panic with UnliftedFFITypes+CApiFFI -----------------------------------+--------------------------------------- Reporter: hvr | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time crash Unknown/Multiple | Test Case: Difficulty: Unknown | Blocking: Blocked By: | Related Tickets: | -----------------------------------+--------------------------------------- The following code fails to compile with at least GHC 7.6, 7.8 and HEAD: {{{#!hs import GHC.Prim import Foreign.C type GmpLimb = CULong type GmpSize = CLong -- mp_limb_t mpn_add_1 (mp_limb_t *rp, const mp_limb_t *s1p, mp_size_t n, mp_limb_t s2limb) foreign import capi unsafe "gmp.h mpn_add_1" c_mpn_add_1 :: MutableByteArray# s -> ByteArray# -> GmpSize -> GmpLimb -> IO GmpLimb }}} with the following compile error message: {{{ ghc: panic! (the 'impossible' happened) (GHC version 7.9.20140704 for x86_64-unknown-linux): toCType MutableByteArray# s Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Otoh, replacing `capi` with `ccall` makes the code compile just fine -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9274 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9274: GHC panic with UnliftedFFITypes+CApiFFI ---------------------------------------+----------------------------------- Reporter: hvr | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- Comment (by hvr): Here's a simpler example (stolen from `Data.ByteString.Short.Internal` which uses `ccall`): {{{#!hs {-# LANGUAGE MagicHash #-} {-# LANGUAGE CApiFFI #-} {-# LANGUAGE UnliftedFFITypes #-} foreign import capi unsafe "string.h memcmp" c_memcmp_ByteArray :: ByteArray# -> ByteArray# -> CSize -> IO CInt }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9274#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9274: GHC panic with UnliftedFFITypes+CApiFFI -------------------------------------+------------------------------------- Reporter: hvr | Owner: igloo Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Differential Revisions: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- Changes (by simonpj): * owner: => igloo Comment: Igloo, you are the man who implemented the `CApi` stuff. Might you look into this? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9274#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9274: GHC panic with UnliftedFFITypes+CApiFFI -------------------------------------+------------------------------------- Reporter: hvr | Owner: igloo Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D4092 Wiki Page: | -------------------------------------+------------------------------------- Changes (by hvr): * status: new => patch * differential: => phab:D4092 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9274#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9274: GHC panic with UnliftedFFITypes+CApiFFI -------------------------------------+------------------------------------- Reporter: hvr | Owner: igloo Type: bug | Status: patch Priority: high | Milestone: 8.2.2 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D4092 Wiki Page: | -------------------------------------+------------------------------------- Changes (by hvr): * priority: normal => high * milestone: => 8.2.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9274#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9274: GHC panic with UnliftedFFITypes+CApiFFI
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: igloo
Type: bug | Status: patch
Priority: high | Milestone: 8.2.2
Component: Compiler | Version: 7.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): phab:D4092
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#9274: GHC panic with UnliftedFFITypes+CApiFFI -------------------------------------+------------------------------------- Reporter: hvr | Owner: igloo Type: bug | Status: merge Priority: high | Milestone: 8.2.2 Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D4092 Wiki Page: | -------------------------------------+------------------------------------- Changes (by hvr): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9274#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9274: GHC panic with UnliftedFFITypes+CApiFFI -------------------------------------+------------------------------------- Reporter: hvr | Owner: igloo Type: bug | Status: closed Priority: high | Milestone: 8.2.2 Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D4092 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.2` in 95c1feeb9ce9b2d6a9453dc4da148b80a5ddce3d. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9274#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC