[GHC] #8281: The impossible happened: primRepToFFIType

GHC ghc-devs at haskell.org
Fri Sep 21 13:02:35 UTC 2018


#8281: The impossible happened: primRepToFFIType
-------------------------------------+-------------------------------------
        Reporter:  tibbe             |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.6.2
      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:D3619
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by hvr):

 Fwiw, re documenting `UnliftedFFITypes` for unpinned `ByteArray#s` I
 (re)stumbled over this old authoritative sounding email
 (https://mail.haskell.org/pipermail/haskell-cafe/2014-June/114761.html)
 from Johan Tibell which stated

 > There is a way to pass an unpinned `ByteArray#` (or `MutableByteArray#`,
 but the former seems right in your case) to a foreign call, using the
 `UnliftedFFITypes` language extension. The `ByteArray#` is **guaranteed to
 not to be moved for the duration of the call**. The code should treat the
 `ByteArray#` argument as if it was a pointer to bytes. You will need to do
 any address offset computations on the C side (i.e. pass any offsets you
 need as extra argument to your C function).

 ...which might explain why there's a lot of code out there (including my
 own) which relies on that guarantee to be upheld (including for `safe` FFI
 calls).

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8281#comment:39>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list