mikera / vectorz-clj

Fast matrix and vector maths library for Clojure - as a core.matrix implementation
203 stars 19 forks source link

IllegalStateExceptions may be caused by AOT'ed code in Clojure 1.11 #74

Closed sdedovic closed 1 year ago

sdedovic commented 1 year ago

Found this bug and (somewhat) a solution, posting here for reference and in case this causes an issue for someone down the road.

The error, from calling clojure.core.matrix.linear/norm is: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core.matrix.impl.mathsops/abs

Full Stacktrace and System Info ``` java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core.matrix.impl.mathsops/abs at clojure.lang.Var$Unbound.throwArity(Var.java:45) at clojure.lang.AFn.invoke(AFn.java:32) at clojure.core$map$fn__5935.invoke(core.clj:2770) at clojure.lang.LazySeq.sval(LazySeq.java:42) at clojure.lang.LazySeq.seq(LazySeq.java:51) at clojure.lang.LazySeq.first(LazySeq.java:73) at clojure.lang.RT.first(RT.java:692) at clojure.core$first__5449.invokeStatic(core.clj:55) at clojure.core$first__5449.invoke(core.clj:55) at clojure.core.matrix.impl.sequence$fn__8123.invokeStatic(sequence.cljc:117) at clojure.core.matrix.impl.sequence$fn__8123.invoke(sequence.cljc:114) at clojure.core.matrix.protocols$fn__468$G__420__473.invoke(protocols.cljc:75) at clojure.core.matrix.impl.persistent_vector$persistent_vector_coerce.invokeStatic(persistent_vector.cljc:96) at clojure.core.matrix.impl.persistent_vector$persistent_vector_coerce.invoke(persistent_vector.cljc:93) at clojure.core.matrix.impl.persistent_vector$fn__5183.invokeStatic(persistent_vector.cljc:138) at clojure.core.matrix.impl.persistent_vector$fn__5183.invoke(persistent_vector.cljc:125) at clojure.core.matrix.protocols$fn__381$G__318__388.invoke(protocols.cljc:40) at clojure.core.matrix.impl.common$construct_matrix.invokeStatic(common.cljc:52) at clojure.core.matrix.impl.common$construct_matrix.invoke(common.cljc:48) at clojure.core.matrix.impl.common$mapmatrix.invokeStatic(common.cljc:70) at clojure.core.matrix.impl.common$mapmatrix.invoke(common.cljc:58) at clojure.core.matrix.impl.persistent_vector$fn__5735.invokeStatic(persistent_vector.cljc:651) at clojure.core.matrix.impl.persistent_vector$fn__5735.invoke(persistent_vector.cljc:637) at clojure.core.matrix.protocols$fn__3932$G__3923__3953.invoke(protocols.cljc:1041) at clojure.core.matrix.impl.defaults$fn__8013.invokeStatic(defaults.cljc:2418) at clojure.core.matrix.impl.defaults$fn__8013.invoke(defaults.cljc:2413) at clojure.core.matrix.protocols$fn__4704$G__4699__4711.invoke(protocols.cljc:1225) at clojure.core.matrix.linear$norm.invokeStatic(linear.cljc:21) at clojure.core.matrix.linear$norm.invoke(linear.cljc:9) at clojure.core.matrix.linear$norm.invokeStatic(linear.cljc:20) at clojure.core.matrix.linear$norm.invoke(linear.cljc:9) ... ``` Tested on previously functioning code with - Linux - OpenJDK Runtime Environment Temurin-17.0.5+8 - Clojure 1.11.1

This is a known bug (CLJ-2712) and fixed in Clojure 1.12. I was able to use the 1.12.0-alpha1 release and it works fine now.

I have not tried any AOT solutions, nor other versions of Clojure, nor other JVMs.