You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. We are using Ctypes to bind a fairly large amount of C-code. A recent optimization was to use Bigstrings (really Bigarray of type char) to pass data across the boundary (via bigarray_start).
This works unless the C function called runs callbacks into OCaml. It seems then that Ocaml can de-allocate the bigstring that was originally passed in.
Is there a best practice I am missing?
I was chatting with some folk, and they thought that a mode which generated the normal CAMLparam macros might fix the issue - in the same way that the concurrency parameter does at the moment, but without releasing the runtime lock.
At the moment we must hold a reference across the C-call with callbacks. It's not pretty. Do you think an option to include the normal FFI protection might be possible? And would work?
This discussion was converted from issue #611 on April 26, 2023 09:20.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi. We are using Ctypes to bind a fairly large amount of C-code. A recent optimization was to use Bigstrings (really Bigarray of type char) to pass data across the boundary (via bigarray_start).
This works unless the C function called runs callbacks into OCaml. It seems then that Ocaml can de-allocate the bigstring that was originally passed in.
Is there a best practice I am missing?
I was chatting with some folk, and they thought that a mode which generated the normal CAMLparam macros might fix the issue - in the same way that the concurrency parameter does at the moment, but without releasing the runtime lock.
At the moment we must hold a reference across the C-call with callbacks. It's not pretty. Do you think an option to include the normal FFI protection might be possible? And would work?
Beta Was this translation helpful? Give feedback.
All reactions