clj-commons / potemkin

some ideas which are almost good
572 stars 53 forks source link

Reliable JVM crash using definterface+ #57

Open glchapman opened 5 years ago

glchapman commented 5 years ago

I'm not sure if this is properly a Potemkin, Clojure, or JVM bug, but I thought I'd start by reporting it here. Please let me know if you think it belongs elsewhere. Anyway, I can reliably crash JVM 11.0.1 on Windows 10 with the attached clojure file (this works with Clojure 1.10 betas 2 and 3 as well as Clojure 1.9). At the repl, I require the temp.clj and run show-bug -- everything is fine. But then I require it again (using :reload true) and run show-bug and the JVM crashes producing the attached error report. jvmcrash.zip

ztellman commented 5 years ago

Ha, wow. I'll dig into this and let you know if I can figure anything out.

glchapman commented 5 years ago

A few more datapoints: 1) this also crashes JVM 11 on Linux (Ubuntu 14 provided by the Windows Subystem for Linux) -- I've attached another error report. jvmcrash_linux.zip 2) I think the crash is happening in the final checkcast to Thing in thing-at. After removing that typehint from the IContainer interface, the crash goes away. 3) I can also get rid of the crash by removing the "already exists" check in definterface+ (so that the macro always emits a definterface). This works even when IContainer includes the Thing typehint.

ztellman commented 5 years ago

Interesting. The third item suggests to me that the original interface may be getting GCed from permgen, even though it's still referenced. I still haven't had a chance to look at this, but this is very helpful, thank you.

KingMob commented 1 year ago

Not 100% sure it's related, but there's still an error of some sort., albeit, not a crash.

In JDK 17, Clojure 1.11.1, after reloading and rerunning show-bug, I get:

Execution error (LinkageError) at temp.Container/thing_at (temp.clj:11). loader constraint violation: loader clojure.lang.DynamicClassLoader @194cd536 wants to load class temp.Thing. A different class with the same name was previously loaded by clojure.lang.DynamicClassLoader @4e13bf71. (temp.Thing is in unnamed module of loader clojure.lang.DynamicClassLoader @4e13bf71, parent loader clojure.lang.DynamicClassLoader @6e1630dc)