potemkin icon indicating copy to clipboard operation
potemkin copied to clipboard

Reliable JVM crash using definterface+

Open glchapman opened this issue 5 years ago • 4 comments

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

glchapman avatar Oct 22 '18 21:10 glchapman

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

ztellman avatar Oct 22 '18 21:10 ztellman

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.

glchapman avatar Oct 24 '18 18:10 glchapman

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.

ztellman avatar Oct 24 '18 19:10 ztellman

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)

KingMob avatar Oct 04 '22 07:10 KingMob