I’m not sure if this should be a bug report yet, hence starting a discussion here. I just wrote some seemingly innocuous code (no FFI, no Obj.magic or other tricks) that should run fine (and does when compiled with the native compiler), but segfaults when run with ocaml.
I will say that there is moderate usage of objects, lists, and folding. But nothing extreme (in my opinion). Specifically the line that causes the segfault is the last line:
On my side your code runs fine in the toplevel (I’ve tested 4.11.1 and 4.12.0).
It’s hard to find what happens in your case without more details, but one possibility is that your .ocamlinit contains some code that interferes in some way. You can try ocaml -noinit and see if it changes anything.
It would be helpful if you could also mention whether the problem occurs with the bytecode compiler too or only the toplevel.
I was able to reproduce in 4.10.1 with the following code, but it crashes only if I invoke it via ocaml foo.ml, it works fine if the code is typed into the toplevel.
let x =
object
method f = ""
end
let _ =
(object method f = x#f end)#f
Indeed, the issue seems to occur for all the methods generated by CamlinternalOO.send_*. I was able to reproduce the segfault for at least send_const and send_env.
Ah, indeed, this is on 4.10.0, running with ocaml. Thanks for confirming, sorry for the missing info. Reproducing the minimal example (segfault) on my end too. Thanks!