Embedding Julia in Java example, "Unreachable reached"

Hello,

I am trying to embed julia into a Java library. However, the java code ends up crashing with the following error “Unreachable reached at ”.

I managed to put together a minimal example which I posted in a GItHub Gist:

https://gist.github.com/samtkaplan/35a1ce57145143b6e34f77ced8096611

The files in the Gist should be placed in the following directory structure:

src/makefile
src/org_foo_bug_jni_Bug.c
src/org_foo_bug_jni_Bug.h
src/org/foo/bug/jni/Bug.java
demo/org/foo/bug/jni/Demo.java

Then, you can compile the code with,

cd src
make
make install
cd ..

Then, you can run the demo that produces the crash with,

cd demo
javac -cp ../deps/usr/share/java/bug.jar org/foo/bug/jni/Demo.java
env LD_PRELOAD="libjulia.so" java -cp .:../deps/usr/share/java/bug.jar -Djava.library.path=../deps/usr/lib org.foo.bug.jni.Demo

Note that if you remove the jl_eval_string("using Pkg") line in org_foo_bug_jni_Bug.c or replace it with something like jl_eval_string("println(\"Hello\")"), then the program runs without crashing.

As a secondary question, I’m not sure why the “LD_PRELOAD” is required. I got that tip from another Discorse topic thread which I’m having troubles finding at the moment.

Thanks for your time. I’m using julia 1.0.1 and java 1.6

Sam