Hi there,
I hit this issue in one of my projects that uses Clojure Spec. I made a simple project to reproduce the issue: https://github.com/alzadude/cljc-hello-world/tree/graalvm-spec-issue
I'm trying to use Graal native-image
with the Clojure patch applied to create a working binary. However, when I used the patched Clojure jar, I am still getting the "unbalanced monitors" error. What am I doing wrong?
Thanks!
1 Build clojure with the patch applied
cd /mnt/d/Projects/clojure
patch -p1 < /mnt/c/Users/alex/Downloads/CLJ-1472-reentrant-finally2.patch
mvn clean
mvn -Plocal install -Dmaven.test.skip=true
2 Try and create Graalvm native image using clj/deps.edn
cd /mnt/d/Projects/cljc-hello-world
GRAALVM_HOME=/usr/local/graalvm-ce-19.2.0.1/ clojure -Anative-image
I still get "unbalanced monitors", even though the patch is applied:
Cleaning target
Creating target/classes
Compiling hello-world.core
Creating target/cljc-hello-world
ERROR! Warning: Aborting stand-alone image build. unbalanced monitors: mismatch at monitorexit, 96|LoadField#lockee__5436__auto__ != 3|LoadField#lockee__5436__auto__
Detailed message:
Call path from entry point to clojure.spec.gen.alpha$dynaload$fn__2628.invoke():
at clojure.spec.gen.alpha$dynaload$fn__2628.invoke(alpha.clj:21)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Warning: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Warning: Image 'target/cljc-hello-world' is a fallback image that requires a JDK for execution (use --no-fallback to suppress fallback image generation).
3 Try and create Graalvm native image using native-image and explicit classpath, to rule out issues with deps.edn/cambada etc
cd /mnt/d/Projects/cljc-hello-world
clojure -Auberjar
/usr/local/graalvm-ce-19.2.0.1/bin/native-image --class-path ../clojure/target/clojure-1.11.0-master-SNAPSHOT.jar --report-unsupported-elements-at-runtime --initialize-at-build-time -jar ./target/cljc-hello-world-1.0.0-SNAPSHOT-standalone.jar -H:Name=./target/cljc-hello-world
I still get "unbalanced monitors":
Build on Server(pid: 10328, port: 64314)*
[./target/cljc-hello-world:10328] classlist: 5,817.52 ms
[./target/cljc-hello-world:10328] (cap): 2,576.68 ms
[./target/cljc-hello-world:10328] setup: 3,923.40 ms
[./target/cljc-hello-world:10328] analysis: 11,800.59 ms
Warning: Aborting stand-alone image build. unbalanced monitors: mismatch at monitorexit, 96|LoadField#lockee__5436__auto__ != 3|LoadField#lockee__5436__auto__
Detailed message:
Call path from entry point to clojure.spec.gen.alpha$dynaload$fn__2628.invoke():
at clojure.spec.gen.alpha$dynaload$fn__2628.invoke(alpha.clj:21)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Warning: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Build on Server(pid: 10328, port: 64314)
[./target/cljc-hello-world:10328] classlist: 217.19 ms
[./target/cljc-hello-world:10328] (cap): 1,244.81 ms
[./target/cljc-hello-world:10328] setup: 1,535.89 ms
[./target/cljc-hello-world:10328] (typeflow): 1,309.40 ms
[./target/cljc-hello-world:10328] (objects): 1,430.65 ms
[./target/cljc-hello-world:10328] (features): 120.57 ms
[./target/cljc-hello-world:10328] analysis: 2,906.19 ms
[./target/cljc-hello-world:10328] (clinit): 88.70 ms
[./target/cljc-hello-world:10328] universe: 250.93 ms
[./target/cljc-hello-world:10328] (parse): 315.62 ms
[./target/cljc-hello-world:10328] (inline): 739.40 ms
[./target/cljc-hello-world:10328] (compile): 3,100.68 ms
[./target/cljc-hello-world:10328] compile: 4,401.60 ms
[./target/cljc-hello-world:10328] image: 296.36 ms
[./target/cljc-hello-world:10328] write: 195.80 ms
[./target/cljc-hello-world:10328] [total]: 9,868.80 ms
Warning: Image './target/cljc-hello-world' is a fallback image that requires a JDK for execution (use --no-fallback to suppress fallback image generation).