inline-rust icon indicating copy to clipboard operation
inline-rust copied to clipboard

To what extent does inline-rust allow for memory safety?

Open georgewsinger opened this issue 6 years ago • 1 comments

This is a theoretical question and perhaps not the best place to ask except I wanted to hear the author's perpsective: to what extent could one achieve memory safety (with Haskell FFI + inline-rust) if one were to

  1. Use inline-rust for all FFI calls.
  2. Avoid using any Foreign.Ptr.* calls (or any other functions) which have the capacity to manipulate pointers from outside the purview of the rust compiler.

If one followed these two rules, could one achieve memory safety in a Haskell project that uses lots of FFI?

georgewsinger avatar Jan 16 '19 23:01 georgewsinger

I think it sort of depends on what exactly you mean with 'memory safety'. Haskell's lazy nature means that you can create ridiculously large thunks that will end up never being resolved/used but might stick around in memory.

This kind of memory leaking is however also not breaking Rust's memory safety guarantees.

Qqwy avatar Sep 28 '19 10:09 Qqwy