Calling embedding api from within a ccall originating from Julia

I’m attempting to integrate Julia into an existing Rust system. The julia embedding api works great when I have a rust executable calling into it, but if I try to call the same code from within a julia notebook it will segfault. Is this unsupported or is there something that I am missing in how julia is constructed? Thanks!

#[no_mangle]
pub unsafe extern "C" fn bootstrap() {
  if jl_is_initialized() == 0 {
    jl_init()
  }

  let cmd = CString::new("println(123)").unwrap();
  jl_eval_string(cmd.as_ptr()); // segfaults iff ccall from julia
}
1 Like