Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17708
Closed
Open
Created Jan 19, 2020 by Ömer Sinan Ağacan@osa1Maintainer

`foreign import ccall "dynamic"` syntax is not documented, safety properties unknown

I did some searching in the user manual and haddocks (generated from master branch) -- as far as I can see the only documentation we have for the foreign import ccall "dynamic" syntax is this one sentence in Foreign.Ptr haddocs:

-- To convert 'FunPtr' values to corresponding Haskell functions, one
-- can define a /dynamic/ stub for the specific foreign type, e.g.
--
-- > type IntFunction = CInt -> IO ()
-- > foreign import ccall "dynamic"
-- >   mkFun :: FunPtr IntFunction -> IntFunction

Main question I had is whether a function called via a "dynamic" wrapper would have properties of a "safe" call (GC may happen) or an "unsafe" call (no GC during the call).

Looking at the code, I can see that we call dsFImport with safety == PlaySafe, but maybe that's the safety of the mkFun (the wrapper) and not the actual FFI call, I'm not sure.

In any case this should be documented somewhere.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking