
Hello, I have been working with a program that uses FFI to communicate with R for several years, but today there is a segmentation fault while importing functions or data from R. Before giving up on this project, I'm posting a few detail here, in case anybody has ideas...perhaps something changed with FFI? I tried going back to the version of R and ghc where it worked using stack, but no luck. The Haskell code is a modification of the code in the package hR (by Dylan Simon), and here is a function that fails that worked before. It fails with a seg fault on the call to r_install. (s = "parse" when it fails)... foreign import ccall safe "Rf_install" r_Install :: CString -> IO R_EXP rInstall :: String -> IO REXP rInstall s = withCString s r_Install >>= extREXP The types are defined as follows... extREXP :: R_EXP -> IO REXP extREXP = newForeignPtr_ data REXPREC type R_EXP = Ptr REXPREC type REXP = ForeignPtr REXPREC newtype SEXP a = SEXP { unSEXP :: REXP } deriving (Eq, Show) Please let me know if you see anything obviously wrong and in need of improvement, perhaps because of changes to the FFI. Thanks, Dominick

Dominick Samperi
Hello,
I have been working with a program that uses FFI to communicate with R for several years, but today there is a segmentation fault while importing functions or data from R. Before giving up on this project, I'm posting a few detail here, in case anybody has ideas...perhaps something changed with FFI?
Hi Dominick, As far as I know nothing should have changed that would break previously-correct FFI programs. More information would be helpful: Which GHC version are you using? Which platform are you running on? Can you provide a reproducer? If so, please open a ticket [1]. Cheers, - Ben [1] https://gitlab.haskell.org/ghc/ghc/-/issues/new

Hey domninick: what platform are you using?
Is this on an arm flavor mac?
On Thu, Jan 26, 2023 at 5:00 PM Ben Gamari
Dominick Samperi
writes: Hello,
I have been working with a program that uses FFI to communicate with R for several years, but today there is a segmentation fault while importing functions or data from R. Before giving up on this project, I'm posting a few detail here, in case anybody has ideas...perhaps something changed with FFI?
Hi Dominick,
As far as I know nothing should have changed that would break previously-correct FFI programs.
More information would be helpful: Which GHC version are you using? Which platform are you running on? Can you provide a reproducer? If so, please open a ticket [1].
Cheers,
- Ben
[1] https://gitlab.haskell.org/ghc/ghc/-/issues/new _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

No Carter, I'm using a PC, and I think the issue was caused by my own
mistake resulting in bad interaction with R's garbage collector, and was
likely not caused by changes to the ghc FFI API.
On Mon, Jan 30, 2023 at 5:05 PM Carter Schonwald
Hey domninick: what platform are you using?
Is this on an arm flavor mac?
On Thu, Jan 26, 2023 at 5:00 PM Ben Gamari
wrote: Dominick Samperi
writes: Hello,
I have been working with a program that uses FFI to communicate with R for several years, but today there is a segmentation fault while importing functions or data from R. Before giving up on this project, I'm posting a few detail here, in case anybody has ideas...perhaps something changed with FFI?
Hi Dominick,
As far as I know nothing should have changed that would break previously-correct FFI programs.
More information would be helpful: Which GHC version are you using? Which platform are you running on? Can you provide a reproducer? If so, please open a ticket [1].
Cheers,
- Ben
[1] https://gitlab.haskell.org/ghc/ghc/-/issues/new _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
participants (3)
-
Ben Gamari
-
Carter Schonwald
-
Dominick Samperi