graalvm

Ingy döt Net 2024-06-05T21:48:55.368069Z

Has anyone come across this error:

Error: Unsupported features in 2 methods
Detailed message:
Error: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
 This frame state: [locals: [_,3,_,_,_,_,_,_,_] stack: [6] locks: [] rethrowException]
Other frame state: [locals: [_,3,_,_,_,_,_,_,_] stack: [20] locks: [13 / 4] rethrowException]
Parser context: clojure.tools.logging$fn__328$log_uncapture_BANG___332.invoke(logging.clj:188) [bci: 15, intrinsic: false]
  15: checkcast     #30         // clojure.lang.IFn
  18: aload_0       
  19: getfield      #1          // orig:java.lang.Object
  22: invokeinterface#5, 2       // clojure.lang.IFn.invoke:(java.lang.Object)java.lang.Object

Call path from entry point to clojure.tools.logging$fn__328$log_uncapture_BANG___332.invoke(): 
	at clojure.tools.logging$fn__328$log_uncapture_BANG___332.invoke(logging.clj:184)
	at clojure.core$PrintWriter_on$fn__7574.invoke(core_print.clj:573)
	at clojure.tools.logging.proxy$java.io.ByteArrayOutputStream$ff19274a.toString(Unknown Source)
	at java.lang.String.valueOf(String.java:4465)
	at com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1332)
	at com.oracle.svm.core.jni.functions.JNIFunctions.ThrowNew(JNIFunctions.java:896)
	at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_ThrowNew_837474fdc53acd32de3ea686903bfa38552734c3(generated:0)
Original exception that caused the problem: org.graalvm.compiler.core.common.PermanentBailoutException: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
 This frame state: [locals: [_,3,_,_,_,_,_,_,_] stack: [6] locks: [] rethrowException]
Other frame state: [locals: [_,3,_,_,_,_,_,_,_] stack: [20] locks: [13 / 4] rethrowException]
Parser context: clojure.tools.logging$fn__328$log_uncapture_BANG___332.invoke(logging.clj:188) [bci: 15, intrinsic: false]
  15: checkcast     #30         // clojure.lang.IFn
  18: aload_0       
  19: getfield      #1          // orig:java.lang.Object
  22: invokeinterface#5, 2       // clojure.lang.IFn.invoke:(java.lang.Object)java.lang.Object
more context here: https://gist.github.com/ingydotnet/9a7a2f88666b406a0c5ad1a65446553e#file-out-txt-L205 This is the remaining error I get trying to use native-image with [ferret "0.4.0-171a575"] ( https://clojars.org/ferret/versions/0.4.0-171a575 ) as a dep...

Alex Miller (Clojure team) 2024-06-05T21:57:44.871979Z

that code uses the locking macro that had balanced monitor issues fixed in Clojure 1.10.2

Alex Miller (Clojure team) 2024-06-05T21:58:54.876439Z

in case that is somehow relevant

Ingy döt Net 2024-06-05T22:06:02.151599Z

Cheers, maybe... My code deps on [org.clojure/clojure "1.11.1"] Is it possible that another dep is pulling in another clojure version? I'm guessing so since:

$ ls -l ~/.m2/repository/org/clojure/clojure/
total 44
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.10.0/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.10.1/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.10.3/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.11.1/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 22:05 1.3.0/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 22:05 1.3.0-alpha5/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.4.0/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.5.1/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.6.0/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.8.0/
drwxr-xr-x 2 ingy ingy 4096 Jun  5 21:15 1.9.0/

Ingy döt Net 2024-06-05T22:11:17.577009Z

same result after rm -r ~/.m2 and rebuilding.

Ingy döt Net 2024-06-05T22:11:33.598409Z

But I only see one clojure jar file:

$ find ~/.m2/repository/org/clojure/clojure/ -name '*.jar'
/home/ingy/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar

Ingy döt Net 2024-06-05T22:12:54.510079Z

what's up with the other version dirs?

lread 2024-06-05T22:28:38.965809Z

It looks like ferret has compiled clojure code in it. Which is typically a no-no for clojure libs. And this could mean you are getting an old version of clojure embedded in ferret.

☝️ 1
lread 2024-06-05T22:30:02.106209Z

> what's up with the other version dirs? Do you mean under your m2 repository? That's just versions of clojure that happened to be dependencies that were downloaded during normal everyday usage.

Ingy döt Net 2024-06-05T22:30:37.121379Z

> same result after rm -r ~/.m2 and rebuilding.

lread 2024-06-05T22:30:47.794189Z

Yes that would be expected.

lread 2024-06-05T22:31:10.310169Z

Download ferret jar and look at contents. Lotsa .class files.

Ingy döt Net 2024-06-05T22:31:37.744709Z

what do you mean during normal everyday usage.?

Ingy döt Net 2024-06-05T22:32:15.345359Z

I literally removed the .m2 dir entirely and ran one build command and got all that

lread 2024-06-05T22:32:57.682069Z

Well, when you use clojure for anything. All maven deps are cached under ~/.m2/repository . It's a local-global cache for maven deps.

Ingy döt Net 2024-06-05T22:33:48.371749Z

Right but only one of those dirs has a jar file in it

Ingy döt Net 2024-06-05T22:34:09.935159Z

1.11.1 (my clojure dep)

lread 2024-06-05T22:35:22.555689Z

Your main issue is ferret has what I expect is an old version of the clojure compiler embedded in it.

Alex Miller (Clojure team) 2024-06-05T22:35:40.115689Z

During dep expansion, other Clojure versions may be transitively encountered and their metadata (pom) versions downloaded

Alex Miller (Clojure team) 2024-06-05T22:36:00.367839Z

Agreed that compiled ferret is likely the source of old classes

Ingy döt Net 2024-06-05T22:36:01.134039Z

I see

Ingy döt Net 2024-06-05T22:36:38.884489Z

@lee can you give a URL pointing to what you are talking about? (compiled code in ferret)

lread 2024-06-05T22:43:11.673009Z

Yep, sure! I went to http://repo.clojars.org and found the ferret jar you are using. Then I downloaded it like so:

wget  
Then I had a look at the contents like so:
unzip -l ferret-0.4.0-f402333.jar
When you see .class files in clojure lib that seem like they came from clojure source, it usually means the builder naively included compiled clojure sources. It is rarely a good idea to do this for a lib, and will cause headaches for users of that lib (like it is doing so now for you!)

lread 2024-06-05T22:45:23.748059Z

(since you are using ferret, you'd also find a copy of the jar under your ~/.m2/repository dir)

Ingy döt Net 2024-06-05T22:47:23.807869Z

I see. https://github.com/nakkaya/ferret doesn't have any clojure code in it. I wouldn't have thought to look in the jar, and if I did I wouldn't have had a clue what to look for. Thanks...

lread 2024-06-05T22:48:06.345479Z

It's a thing that happens sometimes and definitely trips folks up.

lread 2024-06-05T22:48:52.435039Z

Oh I just read the ferret readme, I guess it is more intended to be used as an app than a lib.

lread 2024-06-05T22:50:19.013679Z

But anyhoo if you wanna native-image ferret you'll likely have to fork and tweak.

Ingy döt Net 2024-06-05T22:52:59.509909Z

I didn't notice that. That's interesting because I used it as an app and worked great. But then @markus.agwin and I were trying to use it as a lib. @markus.agwin said it worked with JVM as a lib but not with native-image

lread 2024-06-05T22:54:01.729049Z

Yeah, that's just me glancing at the README... what do I know, really? simple_smile

Ingy döt Net 2024-06-05T22:54:06.781479Z

For what we need, I can justify shelling out to an app or turning it into a bb pod...

👍 1
Ingy döt Net 2024-06-05T22:54:49.556629Z

Thanks for the help. Truly appreciated!

lread 2024-06-05T22:56:14.024899Z

My pleasure! Alex had the answer, I just dug in a bit and rambled on about it.

Ingy döt Net 2024-06-05T22:56:40.778099Z

@alexmiller ++ @lee ++