-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't receive function parameters from ocaml5 runtime #148
Comments
nosing around the memory area, I can see the correct values appearing in memory (twice even), but I know too little about either OCaml's or Rust's memory layout to diagnose this issue any further:
|
ok, taking a look at what pub fn select(sel: ocaml::Raw, fst: ocaml::Raw, snd: ocaml::Raw, ext: ocaml::Raw) -> Value {
let sel = ocaml::Value::Raw(sel.into());
let fst = ocaml::Value::Raw(fst.into());
let snd = ocaml::Value::Raw(snd.into());
let ext = ocaml::Value::Raw(ext.into());
eprintln!("select: sel={:?}, fst={:?}, snd={:?}, ext={:?}", sel, fst, snd, ext); This gives the expected result
And I no longer get a segfault on return. So it seems that the macro no longer properly wraps the function parameters? |
Sorry for the delayed reply - this makes sense to me because |
I suspect I'm jumping the gun here, but it doesn't appear possible to reliably receive parameter values from the ocaml5 runtime: the sys::Values don't match what is sent from ocaml. Has the ABI changed, perhaps?
First off, every ocaml::func seems to end in a segfault when unpacking the passed parameters, like this one:
Using a native_func gives some more insight into what's happening:
which gives the following output:
These values appear consistent over multiple runs, so I don't think it's reading uninitialized memory, just the wrong locations.
I'll supply a gdb backtrace, but I suspect it's of little value given the parameter values above:
On the other hand, returning complex values from Rust to OCaml works fine:
This value gets received fine as an
(int * int) option
on the ocaml side.This is using
{git = "https://github.com/zshipko/ocaml-rs", branch="ocaml5"}
But I get the same results in a clean ocaml 5.1.0 switch.
The text was updated successfully, but these errors were encountered: