3 ms·
> I think the FFI could well express this. Just generate a C thunk that converts the value from the stack to a suitable representation. Oh definitely, I'm just
by masklinn 11y ago
> I think the FFI could well express this. Just generate a C thunk that converts the value from the stack to a suitable representation.
Oh definitely, I'm just saying not all of them do (if you follow the link, the Ruby/MRI, CPython and Node FFIs all provide for that at least on the caller side)
> So you make a C FFI call from a safe language to libfoo.so function void foo(char *jsondata) and before the callee returns your safe runtime yanks the data from under it in another thread?
Yup, could happen with a concurrent GC kicking it at an inconvenient time, or with a refcounting GC.
> Yeah, you would also need the FFI to guarantee against this to get safety.
I'm not sure it could (without caller cooperation), best I can see is offer side-channels to "leak" memory (allocate non-managed memory and copy stuff into it) or recommend that you keep an internal strong reference of some sort (e.g. a global list/set).